private static String deriveAlias(RelNode rel) { if (rel instanceof TableScan) { final List<String> names = rel.getTable().getQualifiedName(); if (!names.isEmpty()) { return Util.last(names); } } return null; }
private Pair<String, String> findTableColumnPair(SqlIdentifier identifier, SqlValidatorScope scope) { SqlCall call = SqlUtil.makeCall(getOperatorTable(), identifier); if (call != null) { return null; } SqlQualified qualified = scope.fullyQualify(identifier); List<String> names = qualified.identifier.names; if (names.size() < 2) { return null; } return new Pair<>(names.get(names.size() - 2), Util.last(names)); }
private static String deriveAlias(RelNode rel) { if (rel instanceof TableScan) { final List<String> names = rel.getTable().getQualifiedName(); if (!names.isEmpty()) { return Util.last(names); } } return null; }
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 (DynamicRecordType.isDynamicStarColName(Util.last(fqId.names)) && !DynamicRecordType.isDynamicStarColName(Util.last(id.names))) { SqlNode[] inputs = new SqlNode[2]; inputs[0] = fqId; inputs[1] = SqlLiteral.createCharString( Util.last(id.names), id.getParserPosition()); SqlBasicCall item_call = new SqlBasicCall(
new ValidationError(sourceValue, RESOURCE.viewConstraintNotSatisfied(colName, Util.last(validatorTable.getQualifiedName()))); RelOptUtil.validateValueAgainstConstraint(sourceValue, projectMap.get(colIndex), validationError);
new ValidationError(column.right, RESOURCE.viewConstraintNotSatisfied(columnName, Util.last(validatorTable.getQualifiedName()))); RelOptUtil.validateValueAgainstConstraint(column.right, columnConstraint, validationError);
public void onMatch(RelOptRuleCall call) { final Filter filter = call.rel(0); final Project project = call.rel(1); final List<RexNode> newProjects = new ArrayList<>(project.getProjects()); newProjects.add(filter.getCondition()); final RelOptCluster cluster = filter.getCluster(); RelDataType newRowType = cluster.getTypeFactory().builder() .addAll(project.getRowType().getFieldList()) .add("condition", Util.last(newProjects).getType()) .build(); final RelNode newProject = project.copy(project.getTraitSet(), project.getInput(), newProjects, newRowType); final RexInputRef newCondition = cluster.getRexBuilder().makeInputRef(newProject, newProjects.size() - 1); call.transformTo(filter.copy(filter.getTraitSet(), newProject, newCondition)); } }
/** * Returns whether this identifier is a star, such as "*" or "foo.bar.*". */ public boolean isStar() { return Util.last(names).equals(""); }
public SqlUserDefinedTableMacro(SqlIdentifier opName, SqlReturnTypeInference returnTypeInference, SqlOperandTypeInference operandTypeInference, SqlOperandTypeChecker operandTypeChecker, List<RelDataType> paramTypes, TableMacro tableMacro) { super(Util.last(opName.names), opName, SqlKind.OTHER_FUNCTION, returnTypeInference, operandTypeInference, operandTypeChecker, Objects.requireNonNull(paramTypes), SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION); this.tableMacro = tableMacro; }
@Override public Table extend(final List<RelDataTypeField> fields) { return new ModifiableTable(Util.last(names)) { @Override public RelDataType getRowType(RelDataTypeFactory typeFactory) { ImmutableList<RelDataTypeField> allFields = ImmutableList.copyOf( Iterables.concat( ModifiableTable.this.getRowType(typeFactory).getFieldList(), fields)); return typeFactory.createStructType(allFields); } }; }
/** Creates a call that concatenates patterns; * for use in {@link #match}. */ public RexNode patternConcat(Iterable<? extends RexNode> nodes) { final ImmutableList<RexNode> list = ImmutableList.copyOf(nodes); if (list.size() > 2) { // Convert into binary calls return patternConcat(patternConcat(Util.skipLast(list)), Util.last(list)); } final RelDataType t = getTypeFactory().createSqlType(SqlTypeName.NULL); return getRexBuilder().makeCall(t, SqlStdOperatorTable.PATTERN_CONCAT, list); }
public static MySchemaPlus create(Path path) { final Pair<String, Schema> pair = Util.last(path); final SchemaPlus parent; if (path.size() == 1) { parent = null; } else { parent = create(path.parent()); } return new MySchemaPlus(parent, pair.left, pair.right); }
private void registerTable(final List<String> names, final Table table) { assert names.get(0).equals(DEFAULT_CATALOG); final List<String> schemaPath = Util.skipLast(names); final String tableName = Util.last(names); final CalciteSchema schema = SqlValidatorUtil.getSchema(rootSchema, schemaPath, SqlNameMatchers.withCaseSensitive(true)); schema.add(tableName, table); }
protected RelDataType validateImpl(RelDataType targetRowType) { for (SqlNode withItem : with.withList) { validator.validateWithItem((SqlWithItem) withItem); } final SqlValidatorScope scope2 = validator.getWithScope(Util.last(with.withList.getList())); validator.validateQuery(with.body, scope2, targetRowType); final RelDataType rowType = validator.getValidatedNodeType(with.body); validator.setValidatedNodeType(with, rowType); return rowType; }
private void registerTable(final List<String> names, final Table table) { assert names.get(0).equals(DEFAULT_CATALOG); final List<String> schemaPath = Util.skipLast(names); final String tableName = Util.last(names); final CalciteSchema schema = SqlValidatorUtil.getSchema(rootSchema, schemaPath, SqlNameMatchers.withCaseSensitive(true)); schema.add(tableName, table); }
public static RelOptTableImpl create(RelOptSchema schema, RelDataType rowType, Table table, Path path) { final SchemaPlus schemaPlus = MySchemaPlus.create(path); return new RelOptTableImpl(schema, rowType, Pair.left(path), table, getClassExpressionFunction(schemaPlus, Util.last(path).left, table), table.getStatistic().getRowCount()); }
@Override public RelDataType deriveRowType() { return getCluster().getTypeFactory().createStructType( Pair.right(Util.last(rels).getRowType().getFieldList()), getQuerySpec().fieldNames); }
protected RelDataType validateImpl(RelDataType targetRowType) { final RelDataTypeFactory.Builder builder = validator.getTypeFactory().builder(); for (SqlMoniker moniker : validator.catalogReader.getAllSchemaObjectNames(names)) { final List<String> names1 = moniker.getFullyQualifiedNames(); final SqlValidatorTable table = validator.catalogReader.getTable(names1); builder.add(Util.last(names1), table.getRowType()); } return builder.build(); }
protected RelDataType validateImpl(RelDataType targetRowType) { final RelDataTypeFactory.Builder builder = validator.getTypeFactory().builder(); for (SqlMoniker moniker : validator.catalogReader.getAllSchemaObjectNames(names)) { final List<String> names1 = moniker.getFullyQualifiedNames(); final SqlValidatorTable table = validator.catalogReader.getTable(names1); builder.add(Util.last(names1), table.getRowType()); } return builder.build(); }