use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlNode in project calcite by apache.
the class PlannerImpl method parse.
public SqlNode parse(final String sql) throws SqlParseException {
switch(state) {
case STATE_0_CLOSED:
case STATE_1_RESET:
ready();
}
ensure(State.STATE_2_READY);
SqlParser parser = SqlParser.create(sql, parserConfig);
SqlNode sqlNode = parser.parseStmt();
state = State.STATE_3_PARSED;
return sqlNode;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlNode in project calcite by apache.
the class SqlTypeUtil method makeNullableIfOperandsAre.
/**
* Recreates a given RelDataType with nullability iff any of the operands
* of a call are nullable.
*/
public static RelDataType makeNullableIfOperandsAre(final SqlValidator validator, final SqlValidatorScope scope, final SqlCall call, RelDataType type) {
for (SqlNode operand : call.getOperandList()) {
RelDataType operandType = validator.deriveType(scope, operand);
if (containsNullable(operandType)) {
RelDataTypeFactory typeFactory = validator.getTypeFactory();
type = typeFactory.createTypeWithNullability(type, true);
break;
}
}
return type;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlNode in project calcite by apache.
the class AggChecker method visit.
public Void visit(SqlIdentifier id) {
if (isGroupExpr(id) || id.isStar()) {
// Star may validly occur in "SELECT COUNT(*) OVER w"
return null;
}
// Is it a call to a parentheses-free function?
SqlCall call = SqlUtil.makeCall(validator.getOperatorTable(), id);
if (call != null) {
return call.accept(this);
}
// Didn't find the identifier in the group-by list as is, now find
// it fully-qualified.
// TODO: It would be better if we always compared fully-qualified
// to fully-qualified.
final SqlQualified fqId = scopes.peek().fullyQualify(id);
if (isGroupExpr(fqId.identifier)) {
return null;
}
SqlNode originalExpr = validator.getOriginal(id);
final String exprString = originalExpr.toString();
throw validator.newValidationError(originalExpr, distinct ? RESOURCE.notSelectDistinctExpr(exprString) : RESOURCE.notGroupExpr(exprString));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlNode in project calcite by apache.
the class AggregatingSelectScope method resolve.
// ~ Methods ----------------------------------------------------------------
private Resolved resolve() {
final ImmutableList.Builder<ImmutableList<ImmutableBitSet>> builder = ImmutableList.builder();
List<SqlNode> extraExprs = ImmutableList.of();
Map<Integer, Integer> groupExprProjection = ImmutableMap.of();
if (select.getGroup() != null) {
final SqlNodeList groupList = select.getGroup();
final SqlValidatorUtil.GroupAnalyzer groupAnalyzer = new SqlValidatorUtil.GroupAnalyzer(temporaryGroupExprList);
for (SqlNode groupExpr : groupList) {
SqlValidatorUtil.analyzeGroupItem(this, groupAnalyzer, builder, groupExpr);
}
extraExprs = groupAnalyzer.extraExprs;
groupExprProjection = groupAnalyzer.groupExprProjection;
}
final Set<ImmutableBitSet> flatGroupSets = Sets.newTreeSet(ImmutableBitSet.COMPARATOR);
for (List<ImmutableBitSet> groupSet : Linq4j.product(builder.build())) {
flatGroupSets.add(ImmutableBitSet.union(groupSet));
}
// For GROUP BY (), we need a singleton grouping set.
if (flatGroupSets.isEmpty()) {
flatGroupSets.add(ImmutableBitSet.of());
}
return new Resolved(extraExprs, temporaryGroupExprList, flatGroupSets, groupExprProjection);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlNode in project calcite by apache.
the class GroupByScope method validateExpr.
public void validateExpr(SqlNode expr) {
SqlNode expanded = validator.expandGroupByOrHavingExpr(expr, this, select, false);
// expression needs to be valid in parent scope too
parent.validateExpr(expanded);
}
Aggregations