@Override public SqlNode visit(SqlDynamicParam param) { if (alreadyVisited.add(param)) { RelDataType type = getValidatedNodeType(param); types.add(type); } return param; } });
public List<List<String>> getFieldOrigins(SqlNode sqlQuery) { if (sqlQuery instanceof SqlExplain) { return Collections.emptyList(); } final RelDataType rowType = getValidatedNodeType(sqlQuery); final int fieldCount = rowType.getFieldCount(); if (!sqlQuery.isA(SqlKind.QUERY)) { return Collections.nCopies(fieldCount, null); } final List<List<String>> list = new ArrayList<>(); for (int i = 0; i < fieldCount; i++) { list.add(getFieldOrigin(sqlQuery, i)); } return ImmutableNullableList.copyOf(list); }
public SqlNode validate(SqlNode topNode) { SqlValidatorScope scope = new EmptyScope(this); scope = new CatalogScope(scope, ImmutableList.of("CATALOG")); final SqlNode topNode2 = validateScopedExpression(topNode, scope); final RelDataType type = getValidatedNodeType(topNode2); Util.discard(type); return topNode2; }
public RelDataType getValidatedNodeTypeIfKnown(SqlNode node) { final RelDataType type = nodeToTypeMap.get(node); if (type != null) { return type; } final SqlValidatorNamespace ns = getNamespace(node); if (ns != null) { return ns.getType(); } final SqlNode original = originalExprs.get(node); if (original != null && original != node) { return getValidatedNodeType(original); } if (node instanceof SqlIdentifier) { return getCatalogReader().getNamedType((SqlIdentifier) node); } return null; }
/** Returns the set of field names in the join condition specified by USING * or implicitly by NATURAL, de-duplicated and in order. */ private List<String> usingNames(SqlJoin join) { switch (join.getConditionType()) { case USING: final ImmutableList.Builder<String> list = ImmutableList.builder(); final Set<String> names = catalogReader.nameMatcher().createSet(); for (SqlNode node : (SqlNodeList) join.getCondition()) { final String name = ((SqlIdentifier) node).getSimple(); if (names.add(name)) { list.add(name); } } return list.build(); case NONE: if (join.isNatural()) { final RelDataType t0 = getValidatedNodeType(join.getLeft()); final RelDataType t1 = getValidatedNodeType(join.getRight()); return SqlValidatorUtil.deriveNaturalJoinColumnList( catalogReader.nameMatcher(), t0, t1); } } return null; }
public void validateWithItem(SqlWithItem withItem) { if (withItem.columnList != null) { final RelDataType rowType = getValidatedNodeType(withItem.query); final int fieldCount = rowType.getFieldCount(); if (withItem.columnList.size() != fieldCount) { throw newValidationError(withItem.columnList, RESOURCE.columnCountMismatch()); } SqlValidatorUtil.checkIdentifierListForDuplicates( withItem.columnList.getList(), validationErrorFunction); } else { // Luckily, field names have not been make unique yet. final List<String> fieldNames = getValidatedNodeType(withItem.query).getFieldNames(); final int i = Util.firstDuplicate(fieldNames); if (i >= 0) { throw newValidationError(withItem.query, RESOURCE.duplicateColumnAndNoColumnList(fieldNames.get(i))); } } }
final Permute left = new Permute(join.getLeft(), offset); final int fieldCount = getValidatedNodeType(join.getLeft()).getFieldList().size(); final Permute right = new Permute(join.getRight(), offset + fieldCount); rowType = getValidatedNodeType(from); this.sources = Functions.generate(rowType.getFieldCount(), i -> ImmutableIntList.of(offset + i));
@Override public SqlNode visit(SqlDynamicParam param) { if (alreadyVisited.add(param)) { RelDataType type = getValidatedNodeType(param); types.add(type); } return param; } });
@Override public SqlNode visit(SqlDynamicParam param) { if (alreadyVisited.add(param)) { RelDataType type = getValidatedNodeType(param); types.add(type); } return param; } });
public List<List<String>> getFieldOrigins(SqlNode sqlQuery) { if (sqlQuery instanceof SqlExplain) { return Collections.emptyList(); } final RelDataType rowType = getValidatedNodeType(sqlQuery); final int fieldCount = rowType.getFieldCount(); if (!sqlQuery.isA(SqlKind.QUERY)) { return Collections.nCopies(fieldCount, null); } final List<List<String>> list = new ArrayList<>(); for (int i = 0; i < fieldCount; i++) { list.add(getFieldOrigin(sqlQuery, i)); } return ImmutableNullableList.copyOf(list); }
public List<List<String>> getFieldOrigins(SqlNode sqlQuery) { if (sqlQuery instanceof SqlExplain) { return Collections.emptyList(); } final RelDataType rowType = getValidatedNodeType(sqlQuery); final int fieldCount = rowType.getFieldCount(); if (!sqlQuery.isA(SqlKind.QUERY)) { return Collections.nCopies(fieldCount, null); } final List<List<String>> list = new ArrayList<>(); for (int i = 0; i < fieldCount; i++) { list.add(getFieldOrigin(sqlQuery, i)); } return ImmutableNullableList.copyOf(list); }
public String translate(String name) { final RelDataType underlyingRowType = validator.getValidatedNodeType(call.operand(0)); int i = 0; for (RelDataTypeField field : rowType.getFieldList()) { if (field.getName().equals(name)) { return underlyingRowType.getFieldList().get(i).getName(); } ++i; } throw new AssertionError("unknown field '" + name + "' in rowtype " + underlyingRowType); } }
@Override public String translate(String name) { if (withItem.columnList == null) { return name; } final RelDataType underlyingRowType = validator.getValidatedNodeType(withItem.query); int i = 0; for (RelDataTypeField field : rowType.getFieldList()) { if (field.getName().equals(name)) { return underlyingRowType.getFieldList().get(i).getName(); } ++i; } throw new AssertionError("unknown field '" + name + "' in rowtype " + underlyingRowType); } }
@Override public String translate(String name) { if (withItem.columnList == null) { return name; } final RelDataType underlyingRowType = validator.getValidatedNodeType(withItem.query); int i = 0; for (RelDataTypeField field : rowType.getFieldList()) { if (field.getName().equals(name)) { return underlyingRowType.getFieldList().get(i).getName(); } ++i; } throw new AssertionError("unknown field '" + name + "' in rowtype " + underlyingRowType); } }
public String translate(String name) { final RelDataType underlyingRowType = validator.getValidatedNodeType(call.operand(0)); int i = 0; for (RelDataTypeField field : rowType.getFieldList()) { if (field.getName().equals(name)) { return underlyingRowType.getFieldList().get(i).getName(); } ++i; } throw new AssertionError("unknown field '" + name + "' in rowtype " + underlyingRowType); } }
public SqlNode validate(SqlNode topNode) { SqlValidatorScope scope = new EmptyScope(this); scope = new CatalogScope(scope, ImmutableList.of("CATALOG")); final SqlNode topNode2 = validateScopedExpression(topNode, scope); final RelDataType type = getValidatedNodeType(topNode2); Util.discard(type); return topNode2; }
public SqlNode validate(SqlNode topNode) { SqlValidatorScope scope = new EmptyScope(this); scope = new CatalogScope(scope, ImmutableList.of("CATALOG")); final SqlNode topNode2 = validateScopedExpression(topNode, scope); final RelDataType type = getValidatedNodeType(topNode2); Util.discard(type); return topNode2; }
public RelDataType getValidatedNodeTypeIfKnown(SqlNode node) { final RelDataType type = nodeToTypeMap.get(node); if (type != null) { return type; } final SqlValidatorNamespace ns = getNamespace(node); if (ns != null) { return ns.getType(); } final SqlNode original = originalExprs.get(node); if (original != null && original != node) { return getValidatedNodeType(original); } if (node instanceof SqlIdentifier) { return getCatalogReader().getNamedType((SqlIdentifier) node); } return null; }
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; }
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; }