Java Code Examples for org.apache.calcite.sql.SqlOperator#isAggregator()
The following examples show how to use
org.apache.calcite.sql.SqlOperator#isAggregator() .
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: SqlValidatorImpl.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Validates an expression. * * @param expr Expression * @param scope Scope in which expression occurs */ private void validateExpr(SqlNode expr, SqlValidatorScope scope) { if (expr instanceof SqlCall) { final SqlOperator op = ((SqlCall) expr).getOperator(); if (op.isAggregator() && op.requiresOver()) { throw newValidationError(expr, RESOURCE.absentOverClause()); } } // Call on the expression to validate itself. expr.validateExpr(this, scope); // Perform any validation specific to the scope. For example, an // aggregating scope requires that expressions are valid aggregations. scope.validateExpr(expr); }
Example 2
Source File: SqlValidatorImpl.java From flink with Apache License 2.0 | 6 votes |
/** * Validates an expression. * * @param expr Expression * @param scope Scope in which expression occurs */ private void validateExpr(SqlNode expr, SqlValidatorScope scope) { if (expr instanceof SqlCall) { final SqlOperator op = ((SqlCall) expr).getOperator(); if (op.isAggregator() && op.requiresOver()) { throw newValidationError(expr, RESOURCE.absentOverClause()); } } // Call on the expression to validate itself. expr.validateExpr(this, scope); // Perform any validation specific to the scope. For example, an // aggregating scope requires that expressions are valid aggregations. scope.validateExpr(expr); }
Example 3
Source File: AggVisitor.java From Bats with Apache License 2.0 | 4 votes |
public Void visit(SqlCall call) { final SqlOperator operator = call.getOperator(); // If nested aggregates disallowed or found an aggregate at invalid level if (operator.isAggregator() && !(operator instanceof SqlAbstractGroupFunction) && !operator.requiresOver()) { if (delegate != null) { return operator.acceptCall(delegate, call); } if (aggregate) { return found(call); } } if (group && operator.isGroup()) { return found(call); } // User-defined function may not be resolved yet. if (operator instanceof SqlFunction) { final SqlFunction sqlFunction = (SqlFunction) operator; if (sqlFunction.getFunctionType().isUserDefinedNotSpecificFunction()) { final List<SqlOperator> list = new ArrayList<>(); opTab.lookupOperatorOverloads(sqlFunction.getSqlIdentifier(), sqlFunction.getFunctionType(), SqlSyntax.FUNCTION, list); for (SqlOperator operator2 : list) { if (operator2.isAggregator() && !operator2.requiresOver()) { // If nested aggregates disallowed or found aggregate at invalid // level if (aggregate) { found(call); } } } } } if (call.isA(SqlKind.QUERY)) { // don't traverse into queries return null; } if (call.getKind() == SqlKind.OVER) { if (over) { return found(call); } else { // an aggregate function over a window is not an aggregate! return null; } } return super.visit(call); }
Example 4
Source File: AggVisitor.java From calcite with Apache License 2.0 | 4 votes |
public Void visit(SqlCall call) { final SqlOperator operator = call.getOperator(); // If nested aggregates disallowed or found an aggregate at invalid level if (operator.isAggregator() && !(operator instanceof SqlAbstractGroupFunction) && !operator.requiresOver()) { if (delegate != null) { return operator.acceptCall(delegate, call); } if (aggregate) { return found(call); } } if (group && operator.isGroup()) { return found(call); } // User-defined function may not be resolved yet. if (operator instanceof SqlFunction) { final SqlFunction sqlFunction = (SqlFunction) operator; if (sqlFunction.getFunctionType().isUserDefinedNotSpecificFunction()) { final List<SqlOperator> list = new ArrayList<>(); opTab.lookupOperatorOverloads(sqlFunction.getSqlIdentifier(), sqlFunction.getFunctionType(), SqlSyntax.FUNCTION, list, nameMatcher); for (SqlOperator operator2 : list) { if (operator2.isAggregator() && !operator2.requiresOver()) { // If nested aggregates disallowed or found aggregate at invalid // level if (aggregate) { found(call); } } } } } if (call.isA(SqlKind.QUERY)) { // don't traverse into queries return null; } if (call.getKind() == SqlKind.WITHIN_GROUP) { if (aggregate) { return found(call); } } if (call.getKind() == SqlKind.OVER) { if (over) { return found(call); } else { // an aggregate function over a window is not an aggregate! return null; } } return super.visit(call); }