Java Code Examples for org.apache.calcite.sql.SqlNode#isA()
The following examples show how to use
org.apache.calcite.sql.SqlNode#isA() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetopNamespace.java From Bats with Apache License 2.0 | 6 votes |
public RelDataType validateImpl(RelDataType targetRowType) { switch (call.getKind()) { case UNION: case INTERSECT: case EXCEPT: final SqlValidatorScope scope = validator.scopes.get(call); for (SqlNode operand : call.getOperandList()) { if (!(operand.isA(SqlKind.QUERY))) { throw validator.newValidationError(operand, RESOURCE.needQueryOp(operand.toString())); } validator.validateQuery(operand, scope, targetRowType); } return call.getOperator().deriveType( validator, scope, call); default: throw new AssertionError("Not a query: " + call.getKind()); } }
Example 2
Source File: SqlValidatorImpl.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public List<SqlMoniker> lookupHints(SqlNode topNode, SqlParserPos pos) { SqlValidatorScope scope = new EmptyScope(this); SqlNode outermostNode = performUnconditionalRewrites(topNode, false); cursorSet.add(outermostNode); if (outermostNode.isA(SqlKind.TOP_LEVEL)) { registerQuery( scope, null, outermostNode, outermostNode, null, false); } final SqlValidatorNamespace ns = getNamespace(outermostNode); if (ns == null) { throw new AssertionError("Not a query: " + outermostNode); } Collection<SqlMoniker> hintList = Sets.newTreeSet(SqlMoniker.COMPARATOR); lookupSelectHints(ns, pos, hintList); return ImmutableList.copyOf(hintList); }
Example 3
Source File: SqlValidatorImpl.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private SqlNode validateScopedExpression( SqlNode topNode, SqlValidatorScope scope) { SqlNode outermostNode = performUnconditionalRewrites(topNode, false); cursorSet.add(outermostNode); top = outermostNode; TRACER.trace("After unconditional rewrite: {}", outermostNode); if (outermostNode.isA(SqlKind.TOP_LEVEL)) { registerQuery(scope, null, outermostNode, outermostNode, null, false); } outermostNode.validate(this, scope); if (!outermostNode.isA(SqlKind.TOP_LEVEL)) { // force type derivation so that we can provide it to the // caller later without needing the scope deriveType(scope, outermostNode); } TRACER.trace("After validation: {}", outermostNode); return outermostNode; }
Example 4
Source File: SqlValidatorImpl.java From flink with Apache License 2.0 | 6 votes |
public List<SqlMoniker> lookupHints(SqlNode topNode, SqlParserPos pos) { SqlValidatorScope scope = new EmptyScope(this); SqlNode outermostNode = performUnconditionalRewrites(topNode, false); cursorSet.add(outermostNode); if (outermostNode.isA(SqlKind.TOP_LEVEL)) { registerQuery( scope, null, outermostNode, outermostNode, null, false); } final SqlValidatorNamespace ns = getNamespace(outermostNode); if (ns == null) { throw new AssertionError("Not a query: " + outermostNode); } Collection<SqlMoniker> hintList = Sets.newTreeSet(SqlMoniker.COMPARATOR); lookupSelectHints(ns, pos, hintList); return ImmutableList.copyOf(hintList); }
Example 5
Source File: SqlValidatorImpl.java From flink with Apache License 2.0 | 6 votes |
private SqlNode validateScopedExpression( SqlNode topNode, SqlValidatorScope scope) { SqlNode outermostNode = performUnconditionalRewrites(topNode, false); cursorSet.add(outermostNode); top = outermostNode; TRACER.trace("After unconditional rewrite: {}", outermostNode); if (outermostNode.isA(SqlKind.TOP_LEVEL)) { registerQuery(scope, null, outermostNode, outermostNode, null, false); } outermostNode.validate(this, scope); if (!outermostNode.isA(SqlKind.TOP_LEVEL)) { // force type derivation so that we can provide it to the // caller later without needing the scope deriveType(scope, outermostNode); } TRACER.trace("After validation: {}", outermostNode); return outermostNode; }
Example 6
Source File: SetopNamespace.java From calcite with Apache License 2.0 | 6 votes |
public RelDataType validateImpl(RelDataType targetRowType) { switch (call.getKind()) { case UNION: case INTERSECT: case EXCEPT: final SqlValidatorScope scope = validator.scopes.get(call); for (SqlNode operand : call.getOperandList()) { if (!(operand.isA(SqlKind.QUERY))) { throw validator.newValidationError(operand, RESOURCE.needQueryOp(operand.toString())); } validator.validateQuery(operand, scope, targetRowType); } return call.getOperator().deriveType( validator, scope, call); default: throw new AssertionError("Not a query: " + call.getKind()); } }
Example 7
Source File: SqlValidatorImpl.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
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); }
Example 8
Source File: SqlValidatorImpl.java From flink with Apache License 2.0 | 5 votes |
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); }