public SqlOperandCountRange get(int index) { return allowedRules.get(index).getOperandCountRange(); }
/** * Returns a string describing the expected operand types of a call, e.g. * "SUBSTRING(VARCHAR, INTEGER, INTEGER)" where the name (SUBSTRING in this * example) can be replaced by a specified name. */ public String getAllowedSignatures(String opNameToUse) { assert operandTypeChecker != null : "If you see this, assign operandTypeChecker a value " + "or override this function"; return operandTypeChecker.getAllowedSignatures(this, opNameToUse) .trim(); }
public boolean isOptional(int i) { for (SqlOperandTypeChecker allowedRule : allowedRules) { if (allowedRule.isOptional(i)) { return true; } } return false; }
typeChecker.getOperandCountRange(); for (int n = range.getMin(), max = range.getMax(); n <= max; n++) { final List<List<ValueType>> argValues = final SqlCallBinding binding = new SqlCallBinding(validator, scope, call); if (!typeChecker.checkOperandTypes(binding, false)) { continue;
if (operand.e != null && operand.e.getKind() == SqlKind.DEFAULT && !operandTypeChecker.isOptional(operand.i)) { throw callBinding.getValidator().newValidationError( callBinding.getCall(), return operandTypeChecker.checkOperandTypes( callBinding, throwOnFailure);
public boolean checkOperandTypes( SqlCallBinding callBinding, boolean throwOnFailure) { if (check(callBinding)) { return true; } if (!throwOnFailure) { return false; } if (composition == Composition.OR) { for (SqlOperandTypeChecker allowedRule : allowedRules) { allowedRule.checkOperandTypes(callBinding, true); } } // If no exception thrown, just throw a generic validation // signature error. throw callBinding.newValidationSignatureError(); }
/** Converts a {@link SqlCall} to a {@link RexCall} with a perhaps different * operator. */ private RexNode convertCall( SqlRexContext cx, SqlCall call, SqlOperator op) { final List<SqlNode> operands = call.getOperandList(); final RexBuilder rexBuilder = cx.getRexBuilder(); final SqlOperandTypeChecker.Consistency consistency = op.getOperandTypeChecker() == null ? SqlOperandTypeChecker.Consistency.NONE : op.getOperandTypeChecker().getConsistency(); final List<RexNode> exprs = convertExpressionList(cx, operands, consistency); RelDataType type = rexBuilder.deriveReturnType(op, exprs); return rexBuilder.makeCall(type, op, RexUtil.flatten(exprs, op)); }
typeChecker.getOperandCountRange(); for (int n = range.getMin(), max = range.getMax(); n <= max; n++) { final List<List<ValueType>> argValues = final SqlCallBinding binding = new SqlCallBinding(validator, scope, call); if (!typeChecker.checkOperandTypes(binding, false)) { continue;
if (operand.e != null && operand.e.getKind() == SqlKind.DEFAULT && !operandTypeChecker.isOptional(operand.i)) { throw callBinding.getValidator().newValidationError( callBinding.getCall(), return operandTypeChecker.checkOperandTypes( callBinding, throwOnFailure);
public boolean checkOperandTypes( SqlCallBinding callBinding, boolean throwOnFailure) { if (check(callBinding)) { return true; } if (!throwOnFailure) { return false; } if (composition == Composition.OR) { for (SqlOperandTypeChecker allowedRule : allowedRules) { allowedRule.checkOperandTypes(callBinding, true); } } // If no exception thrown, just throw a generic validation // signature error. throw callBinding.newValidationSignatureError(); }
/** Converts a {@link SqlCall} to a {@link RexCall} with a perhaps different * operator. */ private RexNode convertCall( SqlRexContext cx, SqlCall call, SqlOperator op) { final List<SqlNode> operands = call.getOperandList(); final RexBuilder rexBuilder = cx.getRexBuilder(); final SqlOperandTypeChecker.Consistency consistency = op.getOperandTypeChecker() == null ? SqlOperandTypeChecker.Consistency.NONE : op.getOperandTypeChecker().getConsistency(); final List<RexNode> exprs = convertExpressionList(cx, operands, consistency); RelDataType type = rexBuilder.deriveReturnType(op, exprs); return rexBuilder.makeCall(type, op, RexUtil.flatten(exprs, op)); }
public SqlOperandCountRange get(int index) { return allowedRules.get(index).getOperandCountRange(); }
: Ord.<SqlOperandTypeChecker>zip(allowedRules)) { SqlOperandTypeChecker rule = ord.e; if (!rule.checkOperandTypes(callBinding, false)) { : Ord.<SqlOperandTypeChecker>zip(allowedRules)) { SqlOperandTypeChecker rule = ord.e; if (rule.checkOperandTypes(callBinding, false)) { return true;
/** Converts a {@link SqlCall} to a {@link RexCall} with a perhaps different * operator. */ private RexNode convertCall( SqlRexContext cx, SqlCall call, SqlOperator op) { final List<SqlNode> operands = call.getOperandList(); final RexBuilder rexBuilder = cx.getRexBuilder(); final SqlOperandTypeChecker.Consistency consistency = op.getOperandTypeChecker() == null ? SqlOperandTypeChecker.Consistency.NONE : op.getOperandTypeChecker().getConsistency(); final List<RexNode> exprs = convertExpressionList(cx, operands, consistency); RelDataType type = rexBuilder.deriveReturnType(op, exprs); return rexBuilder.makeCall(type, op, RexUtil.flatten(exprs, op)); }
/** * Returns a string describing the expected operand types of a call, e.g. * "SUBSTRING(VARCHAR, INTEGER, INTEGER)" where the name (SUBSTRING in this * example) can be replaced by a specified name. */ public String getAllowedSignatures(String opNameToUse) { assert operandTypeChecker != null : "If you see this, assign operandTypeChecker a value " + "or override this function"; return operandTypeChecker.getAllowedSignatures(this, opNameToUse) .trim(); }
public boolean isOptional(int i) { for (SqlOperandTypeChecker allowedRule : allowedRules) { if (allowedRule.isOptional(i)) { return true; } } return false; }
/** * Returns a constraint on the number of operands expected by this operator. * Subclasses may override this method; when they don't, the range is * derived from the {@link SqlOperandTypeChecker} associated with this * operator. * * @return acceptable range */ public SqlOperandCountRange getOperandCountRange() { if (operandTypeChecker != null) { return operandTypeChecker.getOperandCountRange(); } // If you see this error you need to override this method // or give operandTypeChecker a value. throw Util.needToImplement(this); }
: Ord.<SqlOperandTypeChecker>zip(allowedRules)) { SqlOperandTypeChecker rule = ord.e; if (!rule.checkOperandTypes(callBinding, false)) { : Ord.<SqlOperandTypeChecker>zip(allowedRules)) { SqlOperandTypeChecker rule = ord.e; if (rule.checkOperandTypes(callBinding, false)) { return true;
final List<RexNode> list = convertExpressionList(cx, call.getOperandList(), op.getOperandTypeChecker().getConsistency()); final RexNode x = list.get(SqlBetweenOperator.VALUE_OPERAND); final RexNode y = list.get(SqlBetweenOperator.LOWER_OPERAND);
public String getAllowedSignatures(SqlOperator op, String opName) { if (allowedSignatures != null) { return allowedSignatures; } if (composition == Composition.SEQUENCE) { throw new AssertionError( "specify allowedSignatures or override getAllowedSignatures"); } StringBuilder ret = new StringBuilder(); for (Ord<SqlOperandTypeChecker> ord : Ord.<SqlOperandTypeChecker>zip(allowedRules)) { if (ord.i > 0) { ret.append(SqlOperator.NL); } ret.append(ord.e.getAllowedSignatures(op, opName)); if (composition == Composition.AND) { break; } } return ret.toString(); }