/** * Validates that a particular feature is enabled. By default, all features * are enabled; subclasses may override this method to be more * discriminating. * * @param feature feature being used, represented as a resource instance * @param context parser position context for error reporting, or null if */ protected void validateFeature( Feature feature, SqlParserPos context) { // By default, do nothing except to verify that the resource // represents a real feature definition. assert feature.getProperties().get("FeatureDefinition") != null; }
void checkNonQueryExpression(ExprContext exprContext) throws ParseException { switch (exprContext) { case ACCEPT_QUERY: throw SqlUtil.newContextException(getPos(), RESOURCE.illegalNonQueryExpression()); } }
void checkQueryExpression(ExprContext exprContext) throws ParseException { switch (exprContext) { case ACCEPT_NON_QUERY: case ACCEPT_SUB_QUERY: case ACCEPT_CURSOR: throw SqlUtil.newContextException(getPos(), RESOURCE.illegalQueryExpression()); } }
jj_consume_token(NE2); if (!this.conformance.isBangEqualAllowed()) { {if (true) throw new ParseException(RESOURCE.bangEqualNotAllowed().str());}
jj_consume_token(SET_MINUS); if (!this.conformance.isMinusAllowed()) { {if (true) throw new ParseException(RESOURCE.minusNotAllowed().str());}
/** * Parses a compound identifier with optional type. */ final public void CompoundIdentifierType(List<SqlNode> list, List<SqlNode> extendList) throws ParseException { final SqlIdentifier name; SqlDataTypeSpec type = null; boolean nullable = true; name = CompoundIdentifier(); if (jj_2_154(2)) { type = DataType(); if (!this.conformance.allowExtend()) { {if (true) throw new ParseException(RESOURCE.extendNotAllowed().str());} } if (jj_2_153(2)) { jj_consume_token(NOT); jj_consume_token(NULL); nullable = false; } else { ; } } else { ; } if (type != null) { extendList.add(name); extendList.add(type.withNullable(nullable)); } list.add(name); }
/** Creates a call to an aggregate function. */ public AggCall aggregateCall(SqlAggFunction aggFunction, boolean distinct, RexNode filter, String alias, Iterable<? extends RexNode> operands) { if (filter != null) { if (filter.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) { throw Static.RESOURCE.filterMustBeBoolean().ex(); } if (filter.getType().isNullable()) { filter = call(SqlStdOperatorTable.IS_TRUE, filter); } } return new AggCallImpl(aggFunction, distinct, filter, alias, ImmutableList.copyOf(operands)); }
@SuppressWarnings("unchecked") private <T> Sequence<T> runQuery(Query<T> query) { Hook.QUERY_PLAN.run(query); final String queryId = UUID.randomUUID().toString(); plannerContext.addNativeQueryId(queryId); query = query.withId(queryId) .withSqlQueryId(plannerContext.getSqlQueryId()); final AuthenticationResult authenticationResult = plannerContext.getAuthenticationResult(); return queryLifecycleFactory.factorize().runSimple(query, authenticationResult, null); }
/** Validates that a query can deliver the modality it promises. Only called * on the top-most SELECT or set operator in the tree. */ private void validateModality(SqlNode query) { final SqlModality modality = deduceModality(query); if (query instanceof SqlSelect) { final SqlSelect select = (SqlSelect) query; validateModality(select, modality, true); } else if (query.getKind() == SqlKind.VALUES) { switch (modality) { case STREAM: throw newValidationError(query, Static.RESOURCE.cannotStreamValues()); } } else { assert query.isA(SqlKind.SET_QUERY); final SqlCall call = (SqlCall) query; for (SqlNode operand : call.getOperandList()) { if (deduceModality(operand) != modality) { throw newValidationError(operand, Static.RESOURCE.streamSetOpInconsistentInputs()); } validateModality(operand); } } }
private void validateNodeFeature(SqlNode node) { switch (node.getKind()) { case MULTISET_VALUE_CONSTRUCTOR: validateFeature(RESOURCE.sQLFeature_S271(), node.getParserPosition()); break; } }
/** * Validates an item in the ORDER BY clause of a SELECT statement. * * @param select Select statement * @param orderItem ORDER BY clause item */ private void validateOrderItem(SqlSelect select, SqlNode orderItem) { switch (orderItem.getKind()) { case DESCENDING: validateFeature(RESOURCE.sQLConformance_OrderByDesc(), orderItem.getParserPosition()); validateOrderItem(select, ((SqlCall) orderItem).operand(0)); return; } final SqlValidatorScope orderScope = getOrderScope(select); validateExpr(orderItem, orderScope); }
private void validateLiteralAsDouble(SqlLiteral literal) { BigDecimal bd = (BigDecimal) literal.getValue(); double d = bd.doubleValue(); if (Double.isInfinite(d) || Double.isNaN(d)) { // overflow throw newValidationError(literal, RESOURCE.numberLiteralOutOfRange(Util.toScientificNotation(bd))); } // REVIEW jvs 4-Aug-2004: what about underflow? }
protected SqlWindow getWindowByName( SqlIdentifier id, SqlValidatorScope scope) { SqlWindow window = null; if (id.isSimple()) { final String name = id.getSimple(); window = scope.lookupWindow(name); } if (window == null) { throw newValidationError(id, RESOURCE.windowNotFound(id.toString())); } return window; }
protected void validateWhereOrOn( SqlValidatorScope scope, SqlNode condition, String clause) { validateNoAggs(aggOrOverOrGroupFinder, condition, clause); inferUnknownTypes( booleanType, scope, condition); condition.validate(this, scope); final RelDataType type = deriveType(scope, condition); if (!SqlTypeUtil.inBooleanFamily(type)) { throw newValidationError(condition, RESOURCE.condMustBeBoolean(clause)); } }
jj_consume_token(NE2); if (!this.conformance.isBangEqualAllowed()) { {if (true) throw new ParseException(RESOURCE.bangEqualNotAllowed().str());}
jj_consume_token(SET_MINUS); if (!this.conformance.isMinusAllowed()) { {if (true) throw new ParseException(RESOURCE.minusNotAllowed().str());}
/** * Parses a compound identifier with optional type. */ final public void CompoundIdentifierType(List<SqlNode> list, List<SqlNode> extendList) throws ParseException { final SqlIdentifier name; SqlDataTypeSpec type = null; boolean nullable = true; name = CompoundIdentifier(); if (jj_2_154(2)) { type = DataType(); if (!this.conformance.allowExtend()) { {if (true) throw new ParseException(RESOURCE.extendNotAllowed().str());} } if (jj_2_153(2)) { jj_consume_token(NOT); jj_consume_token(NULL); nullable = false; } else { ; } } else { ; } if (type != null) { extendList.add(name); extendList.add(type.withNullable(nullable)); } list.add(name); }
void checkNonQueryExpression(ExprContext exprContext) throws ParseException { switch (exprContext) { case ACCEPT_QUERY: throw SqlUtil.newContextException(getPos(), RESOURCE.illegalNonQueryExpression()); } }
void checkQueryExpression(ExprContext exprContext) throws ParseException { switch (exprContext) { case ACCEPT_NON_QUERY: case ACCEPT_SUB_QUERY: case ACCEPT_CURSOR: throw SqlUtil.newContextException(getPos(), RESOURCE.illegalQueryExpression()); } }
/** Creates a call to an aggregate function. */ public AggCall aggregateCall(SqlAggFunction aggFunction, boolean distinct, RexNode filter, String alias, Iterable<? extends RexNode> operands) { if (filter != null) { if (filter.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) { throw Static.RESOURCE.filterMustBeBoolean().ex(); } if (filter.getType().isNullable()) { filter = call(SqlStdOperatorTable.IS_TRUE, filter); } } return new AggCallImpl(aggFunction, distinct, filter, alias, ImmutableList.copyOf(operands)); }