public CalciteContextException newValidationError(SqlNode node, Resources.ExInst<SqlValidatorException> e) { assert node != null; final SqlParserPos pos = node.getParserPosition(); return SqlUtil.newContextException(pos, e); }
private boolean isRowWithDefault(SqlNode operand, int column) { switch (operand.getKind()) { case ROW: final SqlCall row = (SqlCall) operand; return row.getOperandList().size() >= column && row.getOperandList().get(column).getKind() == SqlKind.DEFAULT; } return false; }
/** Returns whether a query uses {@code DEFAULT} to populate a given * column. */ private boolean isValuesWithDefault(SqlNode source, int column) { switch (source.getKind()) { case VALUES: for (SqlNode operand : ((SqlCall) source).getOperandList()) { if (!isRowWithDefault(operand, column)) { return false; } } return true; } return false; }
@Override public Void visit(SqlCall call) { for (int i = 0; i < call.getOperandList().size(); i++) { call.getOperandList().get(i).accept(this); } return null; }
@Override public SqlNode visit(SqlIdentifier id) { if (id.isSimple()) { return id; } SqlOperator operator = id.names.get(0).equals(alpha) ? SqlStdOperatorTable.PREV : SqlStdOperatorTable.LAST; return operator.createCall(SqlParserPos.ZERO, id, SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO)); } }
public RelDataType visit(SqlNodeList nodeList) { // Operand is of a type that we can't derive a type for. If the // operand is of a peculiar type, such as a SqlNodeList, then you // should override the operator's validateCall() method so that it // doesn't try to validate that operand as an expression. throw Util.needToImplement(nodeList); }
public SqlNode go(SqlNode node) { return node.accept(this); } }
UnparseUtil node(SqlNode n) { n.unparse(writer, leftPrec, rightPrec); return this; }
public String functionName() { return functionName.toString(); }
@Override public SqlNode visit(SqlIdentifier id) { if (op == null) { return id; } else { return op.createCall(SqlParserPos.ZERO, id, offset); } } }
UnparseUtil keyword(String... keywords) { for (String k : keywords) { writer.keyword(k); } return this; }
public RelDataType visit(SqlLiteral literal) { return literal.createSqlType(typeFactory); }
private static SqlNode stripOver(SqlNode node) { switch (node.getKind()) { case OVER: return ((SqlCall) node).getOperandList().get(0); default: return node; } }
public SqlNode go() { return root.accept(this); }
private SqlWindow getWindowInOver(SqlNode over) { if (over.getKind() == SqlKind.OVER) { SqlNode window = ((SqlCall) over).getOperandList().get(1); if (window instanceof SqlWindow) { return (SqlWindow) window; } // SqlIdentifier, gets validated elsewhere return null; } return null; }