@SuppressWarnings("deprecation") public boolean isAggregate(SqlNode selectNode) { return aggFinder.findAgg(selectNode) != null; }
public boolean isAggregate(SqlSelect select) { if (getAggregate(select) != null) { return true; } // Also when nested window aggregates are present for (SqlCall call : overFinder.findAll(select.getSelectList())) { assert call.getKind() == SqlKind.OVER; if (isNestedAggregateWindow(call.operand(0))) { return true; } if (isOverAggregateWindow(call.operand(1))) { return true; } } return false; }
/** * Creates a validator. * * @param opTab Operator table * @param catalogReader Catalog reader * @param typeFactory Type factory * @param conformance Compatibility mode */ protected SqlValidatorImpl( SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory, SqlConformance conformance) { this.opTab = Objects.requireNonNull(opTab); this.catalogReader = Objects.requireNonNull(catalogReader); this.typeFactory = Objects.requireNonNull(typeFactory); this.conformance = Objects.requireNonNull(conformance); unknownType = typeFactory.createUnknownType(); booleanType = typeFactory.createSqlType(SqlTypeName.BOOLEAN); rewriteCalls = true; expandColumnReferences = true; aggFinder = new AggFinder(opTab, false, true, false, null); aggOrOverFinder = new AggFinder(opTab, true, true, false, null); overFinder = new AggFinder(opTab, true, false, false, aggOrOverFinder); groupFinder = new AggFinder(opTab, false, false, true, null); aggOrOverOrGroupFinder = new AggFinder(opTab, true, true, true, null); }
protected boolean isOverAggregateWindow(SqlNode node) { return aggFinder.findAgg(node) != null; }
public boolean isAggregate(SqlSelect select) { if (getAggregate(select) != null) { return true; } // Also when nested window aggregates are present for (SqlCall call : overFinder.findAll(select.getSelectList())) { assert call.getKind() == SqlKind.OVER; if (isNestedAggregateWindow(call.operand(0))) { return true; } if (isOverAggregateWindow(call.operand(1))) { return true; } } return false; }
/** * Creates a validator. * * @param opTab Operator table * @param catalogReader Catalog reader * @param typeFactory Type factory * @param conformance Compatibility mode */ protected SqlValidatorImpl( SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory, SqlConformance conformance) { this.opTab = Objects.requireNonNull(opTab); this.catalogReader = Objects.requireNonNull(catalogReader); this.typeFactory = Objects.requireNonNull(typeFactory); this.conformance = Objects.requireNonNull(conformance); unknownType = typeFactory.createUnknownType(); booleanType = typeFactory.createSqlType(SqlTypeName.BOOLEAN); rewriteCalls = true; expandColumnReferences = true; aggFinder = new AggFinder(opTab, false, true, false, null); aggOrOverFinder = new AggFinder(opTab, true, true, false, null); overFinder = new AggFinder(opTab, true, false, false, aggOrOverFinder); groupFinder = new AggFinder(opTab, false, false, true, null); aggOrOverOrGroupFinder = new AggFinder(opTab, true, true, true, null); }
/** If there is at least one call to an aggregate function, returns the * first. */ private SqlNode getAgg(SqlSelect select) { final SelectScope selectScope = getRawSelectScope(select); if (selectScope != null) { final List<SqlNode> selectList = selectScope.getExpandedSelectList(); if (selectList != null) { return aggFinder.findAgg(selectList); } } return aggFinder.findAgg(select.getSelectList()); }
public boolean isAggregate(SqlSelect select) { if (getAggregate(select) != null) { return true; } // Also when nested window aggregates are present for (SqlCall call : overFinder.findAll(select.getSelectList())) { assert call.getKind() == SqlKind.OVER; if (isNestedAggregateWindow(call.operand(0))) { return true; } if (isOverAggregateWindow(call.operand(1))) { return true; } } return false; }
/** * Creates a validator. * * @param opTab Operator table * @param catalogReader Catalog reader * @param typeFactory Type factory * @param conformance Compatibility mode */ protected SqlValidatorImpl( SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory, SqlConformance conformance) { this.opTab = Objects.requireNonNull(opTab); this.catalogReader = Objects.requireNonNull(catalogReader); this.typeFactory = Objects.requireNonNull(typeFactory); this.conformance = Objects.requireNonNull(conformance); unknownType = typeFactory.createUnknownType(); booleanType = typeFactory.createSqlType(SqlTypeName.BOOLEAN); rewriteCalls = true; expandColumnReferences = true; aggFinder = new AggFinder(opTab, false, true, false, null); aggOrOverFinder = new AggFinder(opTab, true, true, false, null); overFinder = new AggFinder(opTab, true, false, false, aggOrOverFinder); groupFinder = new AggFinder(opTab, false, false, true, null); aggOrOverOrGroupFinder = new AggFinder(opTab, true, true, true, null); }
/** * Throws an error if there is an aggregate or windowed aggregate in the * given clause. * * @param aggFinder Finder for the particular kind(s) of aggregate function * @param node Parse tree * @param clause Name of clause: "WHERE", "GROUP BY", "ON" */ private void validateNoAggs(AggFinder aggFinder, SqlNode node, String clause) { final SqlCall agg = aggFinder.findAgg(node); if (agg == null) { return; } final SqlOperator op = agg.getOperator(); if (op == SqlStdOperatorTable.OVER) { throw newValidationError(agg, RESOURCE.windowedAggregateIllegalInClause(clause)); } else if (op.isGroup() || op.isGroupAuxiliary()) { throw newValidationError(agg, RESOURCE.groupFunctionMustAppearInGroupByClause(op.getName())); } else { throw newValidationError(agg, RESOURCE.aggregateIllegalInClause(clause)); } }
SqlNode agg = aggFinder.findAgg(groupList); if (agg != null) { throw newValidationError(agg, RESOURCE.aggregateIllegalInClause(clause));
SqlNode agg = aggFinder.findAgg(orderList); if (agg != null) { throw newValidationError(agg, RESOURCE.aggregateIllegalInOrderBy());
@SuppressWarnings("deprecation") public boolean isAggregate(SqlNode selectNode) { return aggFinder.findAgg(selectNode) != null; }
@SuppressWarnings("deprecation") public boolean isAggregate(SqlNode selectNode) { return aggFinder.findAgg(selectNode) != null; }
protected boolean isOverAggregateWindow(SqlNode node) { return aggFinder.findAgg(node) != null; }
protected boolean isOverAggregateWindow(SqlNode node) { return aggFinder.findAgg(node) != null; }