public CalciteContextException newValidationError(SqlNode node, Resources.ExInst<SqlValidatorException> e) { assert node != null; final SqlParserPos pos = node.getParserPosition(); return SqlUtil.newContextException(pos, e); }
private void validateNodeFeature(SqlNode node) { switch (node.getKind()) { case MULTISET_VALUE_CONSTRUCTOR: validateFeature(RESOURCE.sQLFeature_S271(), node.getParserPosition()); break; } }
public static Pair<Integer, Integer> getReplacePos(SqlNode node, String inputSql) { if (inputSql == null) { return Pair.newPair(0, 0); } String[] lines = inputSql.split("\n"); SqlParserPos pos = node.getParserPosition(); int lineStart = pos.getLineNum(); int lineEnd = pos.getEndLineNum(); int columnStart = pos.getColumnNum() - 1; int columnEnd = pos.getEndColumnNum(); //for the case that sql is multi lines for (int i = 0; i < lineStart - 1; i++) { columnStart += lines[i].length() + 1; } for (int i = 0; i < lineEnd - 1; i++) { columnEnd += lines[i].length() + 1; } //for calcite's bug CALCITE-1875 Pair<Integer, Integer> startEndPos = getPosWithBracketsCompletion(inputSql, columnStart, columnEnd); return startEndPos; }
expanded = SqlStdOperatorTable.AS.createCall( selectItem.getParserPosition(), expanded, new SqlIdentifier(alias, SqlParserPos.ZERO));
public void validateQuery(SqlNode node, SqlValidatorScope scope, RelDataType targetRowType) { final SqlValidatorNamespace ns = getNamespace(node, scope); if (node.getKind() == SqlKind.TABLESAMPLE) { List<SqlNode> operands = ((SqlCall) node).getOperandList(); SqlSampleSpec sampleSpec = SqlLiteral.sampleValue(operands.get(1)); if (sampleSpec instanceof SqlSampleSpec.SqlTableSampleSpec) { validateFeature(RESOURCE.sQLFeature_T613(), node.getParserPosition()); } else if (sampleSpec instanceof SqlSampleSpec.SqlSubstitutionSampleSpec) { validateFeature(RESOURCE.sQLFeatureExt_T613_Substitution(), node.getParserPosition()); } } validateNamespace(ns, targetRowType); switch (node.getKind()) { case EXTEND: // Until we have a dedicated namespace for EXTEND deriveType(scope, node); } if (node == top) { validateModality(node); } validateAccess( node, ns.getTable(), SqlAccessEnum.SELECT); }
/** * 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); }
/** * Registers any sub-queries inside a given call operand, and converts the * operand to a scalar sub-query if the operator requires it. * * @param parentScope Parent scope * @param call Call * @param operandOrdinal Ordinal of operand within call * @see SqlOperator#argumentMustBeScalar(int) */ private void registerOperandSubQueries( SqlValidatorScope parentScope, SqlCall call, int operandOrdinal) { SqlNode operand = call.operand(operandOrdinal); if (operand == null) { return; } if (operand.getKind().belongsTo(SqlKind.QUERY) && call.getOperator().argumentMustBeScalar(operandOrdinal)) { operand = SqlStdOperatorTable.SCALAR_QUERY.createCall( operand.getParserPosition(), operand); call.setOperand(operandOrdinal, operand); } registerSubQueries(parentScope, operand); }
validateFeature(RESOURCE.sQLFeature_F302(), node.getParserPosition()); registerSetop( parentScope, validateFeature(RESOURCE.sQLFeature_E071_03(), node.getParserPosition()); registerSetop( parentScope, if (checkUpdate) { validateFeature(RESOURCE.sQLFeature_E101_03(), node.getParserPosition()); validateFeature(RESOURCE.sQLFeature_F312(), node.getParserPosition()); SqlMerge mergeCall = (SqlMerge) node; MergeNamespace mergeNs = validateFeature(RESOURCE.sQLFeature_S271(), node.getParserPosition()); call = (SqlCall) node; CollectScope cs = new CollectScope(parentScope, usingScope, call);
listNode = SqlStdOperatorTable.SCALAR_QUERY.createCall( listNode.getParserPosition(), listNode); list.set(i, listNode);
value.getParserPosition()); } else { jj_consume_token(-1);
validateFeature(RESOURCE.sQLFeature_E051_01(), select.getModifierNode(SqlSelectKeyword.DISTINCT) .getParserPosition());
value.getParserPosition()); } else { jj_consume_token(-1);
public SqlParserPos pos(int i) { final Object o = list.get(i); return o instanceof ToTreeListItem ? ((ToTreeListItem) o).pos : ((SqlNode) o).getParserPosition(); }
public CalciteContextException newValidationError(SqlNode node, Resources.ExInst<SqlValidatorException> e) { assert node != null; final SqlParserPos pos = node.getParserPosition(); return SqlUtil.newContextException(pos, e); }
value.getParserPosition()); } else { jj_consume_token(-1);
/** Adds a node's position to the list, * and returns this Span. */ public Span add(SqlNode n) { return add(n.getParserPosition()); }
public CalciteContextException newValidationError(SqlNode node, Resources.ExInst<SqlValidatorException> e) { assert node != null; final SqlParserPos pos = node.getParserPosition(); return SqlUtil.newContextException(pos, e); }
/** * Converts an expression "expr" into "expr AS alias". */ public static SqlNode addAlias( SqlNode expr, String alias) { final SqlParserPos pos = expr.getParserPosition(); final SqlIdentifier id = new SqlIdentifier(alias, pos); return SqlStdOperatorTable.AS.createCall(pos, expr, id); }
private void validateNodeFeature(SqlNode node) { switch (node.getKind()) { case MULTISET_VALUE_CONSTRUCTOR: validateFeature(RESOURCE.sQLFeature_S271(), node.getParserPosition()); break; } }
private SqlNode extend(SqlNode table, SqlNodeList extendList) { return SqlStdOperatorTable.EXTEND.createCall( table.getParserPosition().plus(extendList.getParserPosition()), table, extendList); }