/** * Constructs a new validation error for the call. (Do not use this to * construct a validation error for other nodes such as an operands.) * * @param ex underlying exception * @return wrapped exception */ public EigenbaseException newValidationError( Resources.ExInst<SqlValidatorException> ex) { return validator.newValidationError(call, ex); } }
public EigenbaseException newError( SqlValidatorException e) { return validator.newValidationError(call, e); }
public EigenbaseException newError( Resources.ExInst<SqlValidatorException> e) { return validator.newValidationError(call, e); }
/** * Constructs a new validation error for the call. (Do not use this to * construct a validation error for other nodes such as an operands.) * * @param ex underlying exception * * @return wrapped exception */ public EigenbaseException newValidationError( SqlValidatorException ex) { return validator.newValidationError(call, ex); } }
public void validateCall( SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) { // The base method validates all operands. We override because // we don't want to validate the identifier. final List<SqlNode> operands = call.getOperandList(); assert operands.size() == 2; assert operands.get(1) instanceof SqlIdentifier; operands.get(0).validateExpr(validator, scope); SqlIdentifier id = (SqlIdentifier) operands.get(1); if (!id.isSimple()) { throw validator.newValidationError(id, RESOURCE.aliasMustBeSimpleIdentifier()); } }
private static boolean setOperand(SqlNode clonedOperand, SqlNode thatOperand, SqlValidator validator) { if ((thatOperand != null) && !SqlNodeList.isEmptyList(thatOperand)) { if ((clonedOperand == null) || SqlNodeList.isEmptyList(clonedOperand)) { return true; } else { throw validator.newValidationError(clonedOperand, RESOURCE.cannotOverrideWindowAttribute()); } } return false; }
public void validateCall( SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) { // per the SQL std, each string fragment must be on a different line final List<SqlNode> operandList = call.getOperandList(); for (int i = 1; i < operandList.size(); i++) { SqlParserPos prevPos = operandList.get(i - 1).getParserPosition(); final SqlNode operand = operandList.get(i); SqlParserPos pos = operand.getParserPosition(); if (pos.getLineNum() <= prevPos.getLineNum()) { throw validator.newValidationError(operand, RESOURCE.stringFragsOnSameLine()); } } }
public void validateCall( SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) { // The base method validates all operands. We override because // we don't want to validate the identifier. final SqlNode [] operands = call.operands; assert operands.length == 2; assert operands[1] instanceof SqlIdentifier; operands[0].validateExpr(validator, scope); SqlIdentifier id = (SqlIdentifier) operands[1]; if (!id.isSimple()) { throw validator.newValidationError( id, EigenbaseResource.instance().AliasMustBeSimpleIdentifier.ex()); } }
/** * Throws an error if the type is not built-in. */ public RelDataType deriveType(SqlValidator validator) { String name = typeName.getSimple(); // for now we only support builtin datatypes if (SqlTypeName.get(name) == null) { throw validator.newValidationError(this, RESOURCE.unknownDatatypeName(name)); } if (null != collectionsTypeName) { final String collectionName = collectionsTypeName.getSimple(); if (SqlTypeName.get(collectionName) == null) { throw validator.newValidationError(this, RESOURCE.unknownDatatypeName(collectionName)); } } RelDataTypeFactory typeFactory = validator.getTypeFactory(); return deriveType(typeFactory); }
private static void setOperand( final SqlNode [] destOperands, SqlNode [] srcOperands, int i, SqlValidator validator) { final SqlNode thatOperand = srcOperands[i]; if ((thatOperand != null) && !SqlNodeList.isEmptyList(thatOperand)) { final SqlNode clonedOperand = destOperands[i]; if ((clonedOperand == null) || SqlNodeList.isEmptyList(clonedOperand)) { destOperands[i] = thatOperand; } else { throw validator.newValidationError( clonedOperand, EigenbaseResource.instance().CannotOverrideWindowAttribute .ex()); } } }
/** * Constructs a new validation signature error for the call. * * @return signature exception */ public EigenbaseException newValidationSignatureError() { return validator.newValidationError(call, RESOURCE.canNotApplyOp2Type(getOperator().getName(), call.getCallSignature(validator, scope), getOperator().getAllowedSignatures())); }
/** * Throws a validation error if a DISTINCT or ALL quantifier is present but * not allowed. */ protected void validateQuantifier(SqlValidator validator, SqlCall call) { if ((null != call.getFunctionQuantifier()) && !isQuantifierAllowed()) { throw validator.newValidationError(call.getFunctionQuantifier(), RESOURCE.functionQuantifierNotAllowed(call.getOperator().getName())); } }
protected void checkOperandCount( SqlValidator validator, SqlOperandTypeChecker argType, SqlCall call) { SqlOperandCountRange od = call.getOperator().getOperandCountRange(); if (od.isValidCount(call.operandCount())) { return; } if (od.getMin() == od.getMax()) { throw validator.newValidationError(call, RESOURCE.invalidArgCount(call.getOperator().getName(), od.getMin())); } else { throw validator.newValidationError(call, RESOURCE.wrongNumOfArguments()); } }
/** * Throws an error if the type is not built-in. */ public RelDataType deriveType(SqlValidator validator) { String name = typeName.getSimple(); // for now we only support builtin datatypes if (SqlTypeName.get(name) == null) { throw validator.newValidationError( this, EigenbaseResource.instance().UnknownDatatypeName.ex(name)); } if (null != collectionsTypeName) { final String collectionName = collectionsTypeName.getSimple(); if (!(SqlTypeName.get(collectionName) != null)) { throw validator.newValidationError( this, EigenbaseResource.instance().UnknownDatatypeName.ex( collectionName)); } } RelDataTypeFactory typeFactory = validator.getTypeFactory(); return deriveType(typeFactory); }
public void validateCall( SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) { // per the SQL std, each string fragment must be on a different line for (int i = 1; i < call.operands.length; i++) { SqlParserPos prevPos = call.operands[i - 1].getParserPosition(); final SqlNode operand = call.operands[i]; SqlParserPos pos = operand.getParserPosition(); if (pos.getLineNum() <= prevPos.getLineNum()) { throw validator.newValidationError( operand, EigenbaseResource.instance().StringFragsOnSameLine.ex()); } } }
/** * Throws a validation error if a DISTINCT or ALL quantifier is present but * not allowed. */ protected void validateQuantifier(SqlValidator validator, SqlCall call) { if ((null != call.getFunctionQuantifier()) && !isQuantifierAllowed()) { throw validator.newValidationError( call.getFunctionQuantifier(), EigenbaseResource.instance().FunctionQuantifierNotAllowed.ex( call.getOperator().getName())); } }
/** * Constructs a new validation signature error for the call. * * @return signature exception */ public EigenbaseException newValidationSignatureError() { return validator.newValidationError( call, EigenbaseResource.instance().CanNotApplyOp2Type.ex( getOperator().getName(), call.getCallSignature(validator, scope), getOperator().getAllowedSignatures())); }
protected void checkOperandCount( SqlValidator validator, SqlOperandTypeChecker argType, SqlCall call) { SqlOperandCountRange od = call.getOperator().getOperandCountRange(); if (od.isValidCount(call.operands.length)) { return; } if (od.getMin() == od.getMax()) { throw validator.newValidationError( call, EigenbaseResource.instance().InvalidArgCount.ex( call.getOperator().getName(), od.getMin())); } else { throw validator.newValidationError( call, EigenbaseResource.instance().WrongNumOfArguments.ex()); } }
public void validateCall( SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) { assert call.getOperator() == this; assert call.operandCount() == 2; SqlCall aggCall = call.operand(0); if (!aggCall.getOperator().isAggregator()) { throw validator.newValidationError(aggCall, RESOURCE.overNonAggregate()); } validator.validateWindow(call.operand(1), scope, aggCall); validator.validateAggregateParams(aggCall, scope); }
public void validateCall( SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) { assert call.getOperator() == this; final SqlNode [] operands = call.getOperands(); assert operands.length == 2; SqlCall aggCall = (SqlCall) operands[0]; if (!aggCall.getOperator().isAggregator()) { throw validator.newValidationError( aggCall, EigenbaseResource.instance().OverNonAggregate.ex()); } validator.validateWindow(operands[1], scope, aggCall); validator.validateAggregateParams(aggCall, scope); }