/** * Given a table alias, find the corresponding {@link Table} associated with it * */ private Table findTable(String alias) { List<String> names = null; if (tableScope == null) { // no tables to find return null; } for (ScopeChild child : tableScope.children) { if (catalogReader.nameMatcher().matches(child.name, alias)) { names = ((SqlIdentifier) child.namespace.getNode()).names; break; } } if (names == null || names.size() == 0) { return null; } else if (names.size() == 1) { return findTable(catalogReader.getRootSchema(), names.get(0), catalogReader.nameMatcher().isCaseSensitive()); } CalciteSchema.TableEntry entry = SqlValidatorUtil.getTableEntry(catalogReader, names); return entry == null ? null : entry.getTable(); }
private void checkRollUpInUsing(SqlIdentifier identifier, SqlNode leftOrRight) { leftOrRight = stripAs(leftOrRight); // if it's not a SqlIdentifier then that's fine, it'll be validated somewhere else. if (leftOrRight instanceof SqlIdentifier) { SqlIdentifier from = (SqlIdentifier) leftOrRight; Table table = findTable(catalogReader.getRootSchema(), Util.last(from.names), catalogReader.nameMatcher().isCaseSensitive()); String name = Util.last(identifier.names); if (table != null && table.isRolledUp(name)) { throw newValidationError(identifier, RESOURCE.rolledUpNotAllowed(name, "USING")); } } }
if (!catalogReader.nameMatcher().isCaseSensitive()) { names = Lists.transform(names, s -> s.toUpperCase(Locale.ROOT));
@SuppressWarnings("deprecation") @Override public boolean isCaseSensitive() { return nameMatcher.isCaseSensitive(); }
@SuppressWarnings("deprecation") @Override public boolean isCaseSensitive() { return nameMatcher.isCaseSensitive(); }
public RelDataType createTypeFromProjection(final RelDataType type, final List<String> columnNameList) { return SqlValidatorUtil.createTypeFromProjection(type, columnNameList, typeFactory, nameMatcher.isCaseSensitive()); }
public RelDataType createTypeFromProjection(final RelDataType type, final List<String> columnNameList) { return SqlValidatorUtil.createTypeFromProjection(type, columnNameList, typeFactory, nameMatcher.isCaseSensitive()); }
@Override public boolean isCaseSensitive() { return nameMatcher.isCaseSensitive(); }
@Override public boolean isCaseSensitive() { return nameMatcher.isCaseSensitive(); }
/** * Finds and returns {@link CalciteSchema} nested to the given rootSchema * with specified schemaPath. * * <p>Uses the case-sensitivity policy of specified nameMatcher. * * <p>If not found, returns null. * * @param rootSchema root schema * @param schemaPath full schema path of required schema * @param nameMatcher name matcher * * @return CalciteSchema that corresponds specified schemaPath */ public static CalciteSchema getSchema(CalciteSchema rootSchema, Iterable<String> schemaPath, SqlNameMatcher nameMatcher) { CalciteSchema schema = rootSchema; for (String schemaName : schemaPath) { if (schema == rootSchema && nameMatcher.matches(schemaName, schema.getName())) { continue; } schema = schema.getSubSchema(schemaName, nameMatcher.isCaseSensitive()); if (schema == null) { return null; } } return schema; }
/** * Finds and returns {@link CalciteSchema} nested to the given rootSchema * with specified schemaPath. * * <p>Uses the case-sensitivity policy of specified nameMatcher. * * <p>If not found, returns null. * * @param rootSchema root schema * @param schemaPath full schema path of required schema * @param nameMatcher name matcher * * @return CalciteSchema that corresponds specified schemaPath */ public static CalciteSchema getSchema(CalciteSchema rootSchema, Iterable<String> schemaPath, SqlNameMatcher nameMatcher) { CalciteSchema schema = rootSchema; for (String schemaName : schemaPath) { if (schema == rootSchema && nameMatcher.matches(schemaName, schema.getName())) { continue; } schema = schema.getSubSchema(schemaName, nameMatcher.isCaseSensitive()); if (schema == null) { return null; } } return schema; }
/** * Given a table alias, find the corresponding {@link Table} associated with it * */ private Table findTable(String alias) { List<String> names = null; if (tableScope == null) { // no tables to find return null; } for (ScopeChild child : tableScope.children) { if (catalogReader.nameMatcher().matches(child.name, alias)) { names = ((SqlIdentifier) child.namespace.getNode()).names; break; } } if (names == null || names.size() == 0) { return null; } else if (names.size() == 1) { return findTable(catalogReader.getRootSchema(), names.get(0), catalogReader.nameMatcher().isCaseSensitive()); } CalciteSchema.TableEntry entry = SqlValidatorUtil.getTableEntry(catalogReader, names); return entry == null ? null : entry.getTable(); }
/** * Given a table alias, find the corresponding {@link Table} associated with it * */ private Table findTable(String alias) { List<String> names = null; if (tableScope == null) { // no tables to find return null; } for (ScopeChild child : tableScope.children) { if (catalogReader.nameMatcher().matches(child.name, alias)) { names = ((SqlIdentifier) child.namespace.getNode()).names; break; } } if (names == null || names.size() == 0) { return null; } else if (names.size() == 1) { return findTable(catalogReader.getRootSchema(), names.get(0), catalogReader.nameMatcher().isCaseSensitive()); } CalciteSchema.TableEntry entry = SqlValidatorUtil.getTableEntry(catalogReader, names); return entry == null ? null : entry.getTable(); }
catalogReader.nameMatcher().isCaseSensitive()); if (entry != null) { return entry;
private void checkRollUpInUsing(SqlIdentifier identifier, SqlNode leftOrRight) { leftOrRight = stripAs(leftOrRight); // if it's not a SqlIdentifier then that's fine, it'll be validated somewhere else. if (leftOrRight instanceof SqlIdentifier) { SqlIdentifier from = (SqlIdentifier) leftOrRight; Table table = findTable(catalogReader.getRootSchema(), Util.last(from.names), catalogReader.nameMatcher().isCaseSensitive()); String name = Util.last(identifier.names); if (table != null && table.isRolledUp(name)) { throw newValidationError(identifier, RESOURCE.rolledUpNotAllowed(name, "USING")); } } }
private void checkRollUpInUsing(SqlIdentifier identifier, SqlNode leftOrRight) { leftOrRight = stripAs(leftOrRight); // if it's not a SqlIdentifier then that's fine, it'll be validated somewhere else. if (leftOrRight instanceof SqlIdentifier) { SqlIdentifier from = (SqlIdentifier) leftOrRight; Table table = findTable(catalogReader.getRootSchema(), Util.last(from.names), catalogReader.nameMatcher().isCaseSensitive()); String name = Util.last(identifier.names); if (table != null && table.isRolledUp(name)) { throw newValidationError(identifier, RESOURCE.rolledUpNotAllowed(name, "USING")); } } }
Pair.right(validatedFields), SqlValidatorUtil.uniquify(Pair.left(validatedFields), catalogReader.nameMatcher().isCaseSensitive()));
Pair.right(validatedFields), SqlValidatorUtil.uniquify(Pair.left(validatedFields), catalogReader.nameMatcher().isCaseSensitive()));
Pair.right(validatedFields), SqlValidatorUtil.uniquify(Pair.left(validatedFields), catalogReader.nameMatcher().isCaseSensitive()));
Pair.right(validatedFields), SqlValidatorUtil.uniquify(Pair.left(validatedFields), catalogReader.nameMatcher().isCaseSensitive()));