public CalciteContextException newValidationError(SqlNode node, Resources.ExInst<SqlValidatorException> e) { assert node != null; final SqlParserPos pos = node.getParserPosition(); return SqlUtil.newContextException(pos, e); }
public SqlValidatorScope getJoinScope(SqlNode node) { return scopes.get(stripAs(node)); }
for (RelDataTypeField targetField : targetFields) { fields.add( Pair.of(SqlUtil.deriveAliasFromOrdinal(fields.size()), targetField.getType()));
private Pair<String, String> findTableColumnPair(SqlIdentifier identifier, SqlValidatorScope scope) { SqlCall call = SqlUtil.makeCall(getOperatorTable(), identifier); if (call != null) { return null; } SqlQualified qualified = scope.fullyQualify(identifier); List<String> names = qualified.identifier.names; if (names.size() < 2) { return null; } return new Pair<>(names.get(names.size() - 2), Util.last(names)); }
public boolean checkSingleOperandType( SqlCallBinding callBinding, SqlNode node, int iFormalOperand, boolean throwOnFailure) { Util.discard(iFormalOperand); if (SqlUtil.isNullLiteral(node, true)) { if (allowNull) { return true; } if (throwOnFailure) { throw callBinding.newError( RESOURCE.argumentMustNotBeNull( callBinding.getOperator().getName())); } return false; } if (!SqlUtil.isLiteral(node) && !SqlUtil.isLiteralChain(node)) { if (throwOnFailure) { throw callBinding.newError( RESOURCE.argumentMustBeLiteral( callBinding.getOperator().getName())); } return false; } return true; }
scope = newScope; boolean isNullLiteral = SqlUtil.isNullLiteral(node, false); if ((node instanceof SqlDynamicParam) || isNullLiteral) { if (inferredType.equals(unknownType)) { if (!SqlUtil.isNullLiteral(caseCall.getElseOperand(), false)) { inferUnknownTypes( returnType,
@Override public RelDataType getCursorOperand(int ordinal) { final SqlNode operand = call.operand(ordinal); if (!SqlUtil.isCallTo(operand, SqlStdOperatorTable.CURSOR)) { return null; } final SqlCall cursorCall = (SqlCall) operand; final SqlNode query = cursorCall.operand(0); return validator.deriveType(scope, query); }
/** * Returns whether a node is a literal. * * <p>Many constructs which require literals also accept <code>CAST(NULL AS * <i>type</i>)</code>. This method does not accept casts, so you should * call {@link #isNullLiteral} first. * * @param node The node, never null. * @return Whether the node is a literal */ public static boolean isLiteral(SqlNode node) { return isLiteral(node, false); }
if (SqlUtil.isNullLiteral(right, true)) { return null; if (SqlUtil.isLiteral(right)) { return ((SqlLiteral) right).getValue();
/** * Returns whether a node represents the NULL value or a series of nested * <code>CAST(NULL AS type)</code> calls. For example: * <code>isNull(CAST(CAST(NULL as INTEGER) AS VARCHAR(1)))</code> * returns {@code true}. */ public static boolean isNull(SqlNode node) { return isNullLiteral(node, false) || node.getKind() == SqlKind.CAST && isNull(((SqlCall) node).operand(0)); }
SqlUtil.makeCall( validator.getOperatorTable(), curOpId);
public boolean checkSingleOperandType( SqlCallBinding callBinding, SqlNode node, int iFormalOperand, boolean throwOnFailure) { Util.discard(iFormalOperand); if (SqlUtil.isNullLiteral(node, true)) { if (allowNull) { return true; } if (throwOnFailure) { throw callBinding.newError( RESOURCE.argumentMustNotBeNull( callBinding.getOperator().getName())); } return false; } if (!SqlUtil.isLiteral(node) && !SqlUtil.isLiteralChain(node)) { if (throwOnFailure) { throw callBinding.newError( RESOURCE.argumentMustBeLiteral( callBinding.getOperator().getName())); } return false; } return true; }
targetRowType.getFieldList())) { if (!pair.right.getType().isNullable() && SqlUtil.isNullLiteral(pair.left, false)) { throw newValidationError(node, RESOURCE.columnNotNullable(pair.right.getName()));
@Override public RelDataType getCursorOperand(int ordinal) { final SqlNode operand = call.operand(ordinal); if (!SqlUtil.isCallTo(operand, SqlStdOperatorTable.CURSOR)) { return null; } final SqlCall cursorCall = (SqlCall) operand; final SqlNode query = cursorCall.operand(0); return validator.deriveType(scope, query); }
/** * Returns whether a node is a literal. * * <p>Many constructs which require literals also accept <code>CAST(NULL AS * <i>type</i>)</code>. This method does not accept casts, so you should * call {@link #isNullLiteral} first. * * @param node The node, never null. * @return Whether the node is a literal */ public static boolean isLiteral(SqlNode node) { return isLiteral(node, false); }
if (SqlUtil.isNullLiteral(right, true)) { return null; if (SqlUtil.isLiteral(right)) { return ((SqlLiteral) right).getValue();
/** * Returns whether a node represents the NULL value or a series of nested * <code>CAST(NULL AS type)</code> calls. For example: * <code>isNull(CAST(CAST(NULL as INTEGER) AS VARCHAR(1)))</code> * returns {@code true}. */ public static boolean isNull(SqlNode node) { return isNullLiteral(node, false) || node.getKind() == SqlKind.CAST && isNull(((SqlCall) node).operand(0)); }
void checkNonQueryExpression(ExprContext exprContext) throws ParseException { switch (exprContext) { case ACCEPT_QUERY: throw SqlUtil.newContextException(getPos(), RESOURCE.illegalNonQueryExpression()); } }
private boolean shouldCheckForRollUp(SqlNode from) { if (from != null) { SqlKind kind = stripAs(from).getKind(); return kind != SqlKind.VALUES && kind != SqlKind.SELECT; } return false; }
public RelDataType visit(SqlIdentifier id) { SqlCall call = SqlUtil.makeCall(opTab, id); if (call != null) { return call.getOperator().validateOperands(