public boolean fieldExists(String name) { final RelDataType rowType = getRowType(); return validator.catalogReader.field(rowType, name) != null; }
SqlValidatorNamespace lookupFieldNamespace(RelDataType rowType, String name) { final RelDataTypeField field = catalogReader.field(rowType, name); return new FieldNamespace(this, field.getType()); }
public SqlIdentifier fullyQualify(SqlIdentifier identifier) { // If it's a simple identifier, look for an alias. if (identifier.isSimple() && validator.getConformance().isSortByAlias()) { String name = identifier.names.get(0); final SqlValidatorNamespace selectNs = validator.getNamespace(select); final RelDataType rowType = selectNs.getRowType(); if (validator.catalogReader.field(rowType, name) != null) { return identifier; } } return super.fullyQualify(identifier); }
public RelDataType resolveColumn(String name, SqlNode ctx) { final SqlValidatorNamespace selectNs = validator.getNamespace(select); final RelDataType rowType = selectNs.getRowType(); final RelDataTypeField field = validator.catalogReader.field(rowType, name); if (field != null) { return field.getType(); } final SqlValidatorScope selectScope = validator.getSelectScope(select); return selectScope.resolveColumn(name, ctx); }
public String findQualifyingTableName( final String columnName, SqlNode ctx) { int count = 0; String tableName = null; for (Pair<String, SqlValidatorNamespace> child : children) { final RelDataType rowType = child.right.getRowType(); if (validator.catalogReader.field(rowType, columnName) != null) { tableName = child.left; count++; } } switch (count) { case 0: return parent.findQualifyingTableName(columnName, ctx); case 1: return tableName; default: throw validator.newValidationError(ctx, RESOURCE.columnAmbiguous(columnName)); } }
public RelDataType resolveColumn(String columnName, SqlNode ctx) { int found = 0; RelDataType type = null; for (Pair<String, SqlValidatorNamespace> pair : children) { SqlValidatorNamespace childNs = pair.right; final RelDataType childRowType = childNs.getRowType(); final RelDataTypeField field = validator.catalogReader.field(childRowType, columnName); if (field != null) { found++; type = field.getType(); } } switch (found) { case 0: return null; case 1: return type; default: throw validator.newValidationError(ctx, RESOURCE.columnAmbiguous(columnName)); } } }
private RelDataType validateUsingCol(SqlIdentifier id, SqlNode leftOrRight) { if (id.names.size() == 1) { String name = id.names.get(0); final SqlValidatorNamespace namespace = getNamespace(leftOrRight); final RelDataType rowType = namespace.getRowType(); final RelDataTypeField field = catalogReader.field(rowType, name); if (field != null) { if (Collections.frequency(rowType.getFieldNames(), name) > 1) { throw newValidationError(id, RESOURCE.columnInUsingNotUnique(id.toString())); } return field.getType(); } } throw newValidationError(id, RESOURCE.columnNotFound(id.toString())); }
final RelDataType fromRowType = fromNs.getRowType(); final RelDataTypeField field = validator.catalogReader.field(fromRowType, columnName); if (field != null) { return identifier; // it was fine already
SqlIdentifier id = (SqlIdentifier) node; String name = id.getSimple(); RelDataTypeField targetField = catalogReader.field(baseRowType, name); if (targetField == null) { throw newValidationError(id, RESOURCE.unknownTargetColumn(name));
public SqlNode visit(SqlIdentifier id) { // Aliases, e.g. 'select a as x, b from t order by x'. if (id.isSimple() && getConformance().isSortByAlias()) { String alias = id.getSimple(); final SqlValidatorNamespace selectNs = getNamespace(select); final RelDataType rowType = selectNs.getRowTypeSansSystemColumns(); RelDataTypeField field = catalogReader.field(rowType, alias); if (field != null) { return nthSelectItem( field.getIndex(), id.getParserPosition()); } } // No match. Return identifier unchanged. return getScope().fullyQualify(id); }
final RelDataTypeField field = catalogReader.field(type, name); if (field == null) { throw newValidationError(id.getComponent(ord.i),