SqlValidatorUtil.getEnclosingSelectScope(bb.scope); final SqlValidatorNamespace selectNamespace = validator.getNamespace(selectScope.getNode());
protected RelOptTable getTargetTable(SqlNode call) { SqlValidatorNamespace targetNs = validator.getNamespace(call).resolve(); return SqlValidatorUtil.getRelOptTable(targetNs, catalogReader, null, null); }
public RelDataTypeField field(RelDataType rowType, String alias) { return SqlValidatorUtil.lookupField(caseSensitive, rowType, alias); }
/** * Adds an expression to a select list, ensuring that its alias does not * clash with any existing expressions on the list. */ protected void addToSelectList( List<SqlNode> list, Set<String> aliases, List<Map.Entry<String, RelDataType>> fieldList, SqlNode exp, SqlValidatorScope scope, final boolean includeSystemVars) { String alias = SqlValidatorUtil.getAlias(exp, -1); String uniqueAlias = SqlValidatorUtil.uniquify(alias, aliases); if (!alias.equals(uniqueAlias)) { exp = SqlValidatorUtil.addAlias(exp, uniqueAlias); } fieldList.add(Pair.of(uniqueAlias, deriveType(scope, exp))); list.add(exp); }
/** Creates a result based on a single relational expression. */ public Result result(SqlNode node, Collection<Clause> clauses, RelNode rel) { final String alias2 = SqlValidatorUtil.getAlias(node, -1); final String alias3 = alias2 != null ? alias2 : "t"; final String alias4 = SqlValidatorUtil.uniquify( alias3, aliasSet, SqlValidatorUtil.EXPR_SUGGESTER); final String alias5 = alias2 == null || !alias2.equals(alias4) ? alias4 : null; return new Result(node, clauses, alias5, Collections.singletonList(Pair.of(alias4, rel.getRowType()))); }
protected RelDataType uniquifyFields(RelDataType rowType) { return validator.getTypeFactory().createStructType( RelOptUtil.getFieldTypeList(rowType), SqlValidatorUtil.uniquify(rowType.getFieldNames())); }
boolean[] usedDataset = {false}; RelOptTable table = SqlValidatorUtil.getRelOptTable( fromNamespace, catalogReader, if (isNatural) { final List<String> columnList = SqlValidatorUtil.deriveNaturalJoinColumnList( validator.getNamespace(left).getRowType(), validator.getNamespace(right).getRowType());
/** * Creates the SELECT statement that putatively feeds rows into an UPDATE * statement to be updated. * * @param call Call to the UPDATE operator * @return select statement */ protected SqlSelect createSourceSelectForUpdate(SqlUpdate call) { final SqlNodeList selectList = new SqlNodeList(SqlParserPos.ZERO); selectList.add(new SqlIdentifier("*", SqlParserPos.ZERO)); int ordinal = 0; for (SqlNode exp : call.getSourceExpressionList()) { // Force unique aliases to avoid a duplicate for Y with // SET X=Y String alias = SqlUtil.deriveAliasFromOrdinal(ordinal); selectList.add(SqlValidatorUtil.addAlias(exp, alias)); ++ordinal; } SqlNode sourceTable = call.getTargetTable(); if (call.getAlias() != null) { sourceTable = SqlValidatorUtil.addAlias( sourceTable, call.getAlias().getSimple()); } return new SqlSelect(SqlParserPos.ZERO, null, selectList, sourceTable, call.getCondition(), null, null, null, null, null, null); }
public String deriveAlias( SqlNode node, int ordinal) { return SqlValidatorUtil.getAlias(node, ordinal); }
final RelDataType rightRowType = getNamespace(right).getRowType(); List<String> naturalColumnNames = SqlValidatorUtil.deriveNaturalJoinColumnList( leftRowType, rightRowType);
private static void findAllValidUdfNames( List<String> names, SqlValidator validator, List<SqlMoniker> result) { List<SqlMoniker> objNames = new ArrayList<SqlMoniker>(); SqlValidatorUtil.getSchemaObjectMonikers( validator.getCatalogReader(), names, objNames); for (SqlMoniker objName : objNames) { if (objName.getType() == SqlMonikerType.FUNCTION) { result.add(objName); } } }
/** * Derives the type of a call to this operator. * * <p>This method is an intrinsic part of the validation process so, unlike * {@link #inferReturnType}, specific operators would not typically override * this method. * * @param validator Validator * @param scope Scope of validation * @param call Call to this operator * * @return Type of call */ public RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { for (SqlNode operand : call.operands) { RelDataType nodeType = validator.deriveType(scope, operand); assert nodeType != null; } RelDataType type = validateOperands(validator, scope, call); // Validate and determine coercibility and resulting collation // name of binary operator if needed. type = adjustType(validator, call, type); SqlValidatorUtil.checkCharsetAndCollateConsistentIfCharType(type); return type; }
public RelDataType createTypeFromProjection(final RelDataType type, final List<String> columnNameList) { return SqlValidatorUtil.createTypeFromProjection(type, columnNameList, typeFactory, caseSensitive); }
fieldNames = SqlValidatorUtil.uniquify(fieldNames);
boolean [] usedDataset = { false }; RelOptTable table = SqlValidatorUtil.getRelOptTable( fromNamespace, catalogReader, if (isNatural) { final List<String> columnList = SqlValidatorUtil.deriveNaturalJoinColumnList( validator.getNamespace(left).getRowType(), validator.getNamespace(right).getRowType());
/** * Adds an expression to a select list, ensuring that its alias does not * clash with any existing expressions on the list. */ protected void addToSelectList( List<SqlNode> list, Set<String> aliases, List<Map.Entry<String, RelDataType>> fieldList, SqlNode exp, SqlValidatorScope scope, final boolean includeSystemVars) { String alias = SqlValidatorUtil.getAlias(exp, -1); String uniqueAlias = SqlValidatorUtil.uniquify( alias, aliases, SqlValidatorUtil.EXPR_SUGGESTER); if (!alias.equals(uniqueAlias)) { exp = SqlValidatorUtil.addAlias(exp, uniqueAlias); } fieldList.add(Pair.of(uniqueAlias, deriveType(scope, exp))); list.add(exp); }
/** Creates a result based on a single relational expression. */ public Result result(SqlNode node, Collection<Clause> clauses, RelNode rel) { final String alias2 = SqlValidatorUtil.getAlias(node, -1); final String alias3 = alias2 != null ? alias2 : "t"; final String alias4 = SqlValidatorUtil.uniquify(alias3, aliasSet); final String alias5 = alias2 == null || !alias2.equals(alias4) ? alias4 : null; return new Result(node, clauses, alias5, Collections.singletonList(Pair.of(alias4, rel.getRowType()))); }
public String deriveAlias( SqlNode node, int ordinal) { return SqlValidatorUtil.getAlias(node, ordinal); }
final RelDataType rightRowType = getNamespace(right).getRowType(); List<String> naturalColumnNames = SqlValidatorUtil.deriveNaturalJoinColumnList( leftRowType, rightRowType);