final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); scope.resolve(ImmutableList.of(name), nameMatcher, false, resolved); if (resolved.count() == 1) { ns = resolved.only().namespace;
new SqlValidatorScope.ResolvedImpl(); scope.resolve(id.names.subList(0, i), nameMatcher, false, resolved); if (resolved.count() == 1) {
scope.validator.catalogReader.nameMatcher(); scope.resolve(prefixId.names, nameMatcher, true, resolved); if (resolved.count() == 0) {
new SqlValidatorScope.ResolvedImpl(); scope.resolve(qualified.prefix(), nameMatcher, false, resolved); if (!(resolved.count() == 1)) { return null;
new SqlValidatorScope.ResolvedImpl(); scope.resolve(id.names.subList(0, i), nameMatcher, false, resolved); if (resolved.count() == 1) {
new SqlValidatorScope.ResolvedImpl(); scope.resolve(qualified.prefix(), nameMatcher, false, resolved); if (!(resolved.count() == 1)) { return null;
resolved); assert resolved.count() == 1; final SqlValidatorScope.Resolve resolve = resolved.only(); final RelDataType rowType = resolve.rowType();
resolved); assert resolved.count() == 1; final SqlValidatorScope.Resolve resolve = resolved.only(); final RelDataType rowType = resolve.rowType();
final ResolvedImpl resolved = new ResolvedImpl(); resolveTable(names, nameMatcher, Path.EMPTY, resolved); if (resolved.count() == 1 && resolved.only().remainingNames.isEmpty() && resolved.only().namespace instanceof TableNamespace
final ResolvedImpl resolved = new ResolvedImpl(); resolveTable(names, nameMatcher, Path.EMPTY, resolved); if (resolved.count() == 1 && resolved.only().remainingNames.isEmpty() && resolved.only().namespace instanceof TableNamespace
/** * Resolves a multi-part identifier such as "SCHEMA.EMP.EMPNO" to a * namespace. The returned namespace, never null, may represent a * schema, table, column, etc. */ public static SqlValidatorNamespace lookup( SqlValidatorScope scope, List<String> names) { assert names.size() > 0; final SqlNameMatcher nameMatcher = scope.getValidator().getCatalogReader().nameMatcher(); final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolve(ImmutableList.of(names.get(0)), nameMatcher, false, resolved); assert resolved.count() == 1; SqlValidatorNamespace namespace = resolved.only().namespace; for (String name : Util.skip(names)) { namespace = namespace.lookupChild(name); assert namespace != null; } return namespace; }
public void validateSequenceValue(SqlValidatorScope scope, SqlIdentifier id) { // Resolve identifier as a table. final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolveTable(id.names, catalogReader.nameMatcher(), SqlValidatorScope.Path.EMPTY, resolved); if (resolved.count() != 1) { throw newValidationError(id, RESOURCE.tableNameNotFound(id.toString())); } // We've found a table. But is it a sequence? final SqlValidatorNamespace ns = resolved.only().namespace; if (ns instanceof TableNamespace) { final Table table = ns.getTable().unwrap(Table.class); switch (table.getJdbcTableType()) { case SEQUENCE: case TEMPORARY_SEQUENCE: return; } } throw newValidationError(id, RESOURCE.notASequence(id.toString())); }
public void validateSequenceValue(SqlValidatorScope scope, SqlIdentifier id) { // Resolve identifier as a table. final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolveTable(id.names, catalogReader.nameMatcher(), SqlValidatorScope.Path.EMPTY, resolved); if (resolved.count() != 1) { throw newValidationError(id, RESOURCE.tableNameNotFound(id.toString())); } // We've found a table. But is it a sequence? final SqlValidatorNamespace ns = resolved.only().namespace; if (ns instanceof TableNamespace) { final Table table = ns.getTable().unwrap(Table.class); switch (table.getJdbcTableType()) { case SEQUENCE: case TEMPORARY_SEQUENCE: return; } } throw newValidationError(id, RESOURCE.notASequence(id.toString())); }
/** * Resolves a multi-part identifier such as "SCHEMA.EMP.EMPNO" to a * namespace. The returned namespace, never null, may represent a * schema, table, column, etc. */ public static SqlValidatorNamespace lookup( SqlValidatorScope scope, List<String> names) { assert names.size() > 0; final SqlNameMatcher nameMatcher = scope.getValidator().getCatalogReader().nameMatcher(); final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolve(ImmutableList.of(names.get(0)), nameMatcher, false, resolved); assert resolved.count() == 1; SqlValidatorNamespace namespace = resolved.only().namespace; for (String name : Util.skip(names)) { namespace = namespace.lookupChild(name); assert namespace != null; } return namespace; }
@Override public Map<String, ScopeChild> findQualifyingTableNames(String columnName, SqlNode ctx, SqlNameMatcher nameMatcher) { final Map<String, ScopeChild> map = new HashMap<>(); for (ScopeChild child : children) { final ResolvedImpl resolved = new ResolvedImpl(); resolve(ImmutableList.of(child.name, columnName), nameMatcher, true, resolved); if (resolved.count() > 0) { map.put(child.name, child); } } switch (map.size()) { case 0: return parent.findQualifyingTableNames(columnName, ctx, nameMatcher); default: return map; } }
@Override public Map<String, ScopeChild> findQualifyingTableNames(String columnName, SqlNode ctx, SqlNameMatcher nameMatcher) { final Map<String, ScopeChild> map = new HashMap<>(); for (ScopeChild child : children) { final ResolvedImpl resolved = new ResolvedImpl(); resolve(ImmutableList.of(child.name, columnName), nameMatcher, true, resolved); if (resolved.count() > 0) { map.put(child.name, child); } } switch (map.size()) { case 0: return parent.findQualifyingTableNames(columnName, ctx, nameMatcher); default: return map; } }
private SqlValidatorNamespace getNamespace(SqlIdentifier id, DelegatingScope scope) { if (id.isSimple()) { final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolve(id.names, nameMatcher, false, resolved); if (resolved.count() == 1) { return resolved.only().namespace; } } return getNamespace(id); }
private SqlValidatorNamespace getNamespace(SqlIdentifier id, DelegatingScope scope) { if (id.isSimple()) { final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolve(id.names, nameMatcher, false, resolved); if (resolved.count() == 1) { return resolved.only().namespace; } } return getNamespace(id); }
public void validateSequenceValue(SqlValidatorScope scope, SqlIdentifier id) { // Resolve identifier as a table. final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolveTable(id.names, catalogReader.nameMatcher(), SqlValidatorScope.Path.EMPTY, resolved); if (resolved.count() != 1) { throw newValidationError(id, RESOURCE.tableNameNotFound(id.toString())); } // We've found a table. But is it a sequence? final SqlValidatorNamespace ns = resolved.only().namespace; if (ns instanceof TableNamespace) { final Table table = ns.getTable().unwrap(Table.class); switch (table.getJdbcTableType()) { case SEQUENCE: case TEMPORARY_SEQUENCE: return; } } throw newValidationError(id, RESOURCE.notASequence(id.toString())); }
private SqlValidatorNamespace getNamespace(SqlIdentifier id, DelegatingScope scope) { if (id.isSimple()) { final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolve(id.names, nameMatcher, false, resolved); if (resolved.count() == 1) { return resolved.only().namespace; } } return getNamespace(id); }