public RelDataType get(int row) { SqlCall thisRow = (SqlCall) operands.get(row); return deriveType(scope, thisRow.operand(c)); }
call = (SqlCall) node; if (alias == null) { alias = call.operand(1).toString(); expr = call.operand(0); newExpr = registerFrom( case TABLESAMPLE: call = (SqlCall) node; expr = call.operand(0); newExpr = registerFrom( usingScope, register, ((SqlCall) node).operand(0), enclosingNode, alias, operand = call.operand(0); newOperand = registerFrom( final OverScope overScope = new OverScope(usingScope, call); scopes.put(call, overScope); operand = call.operand(0); newOperand = registerFrom(
private SqlNode stripDot(SqlNode node) { if (node != null && node.getKind() == SqlKind.DOT) { return stripDot(((SqlCall) node).operand(0)); } return node; }
/** Returns the alias of a "expr AS alias" expression. */ private static String alias(SqlNode item) { assert item instanceof SqlCall; assert item.getKind() == SqlKind.AS; final SqlIdentifier identifier = ((SqlCall) item).operand(1); return identifier.getSimple(); }
private static boolean isLateral(SqlNode node) { switch (node.getKind()) { case LATERAL: case UNNEST: // Per SQL std, UNNEST is implicitly LATERAL. return true; case AS: return isLateral(((SqlCall) node).operand(0)); default: return false; } }
@Override public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { if (call.operandCount() == 1 && call.getOperandList().get(0).getKind() == SqlKind.COLLECTION_TABLE) { // do not create ( ) around the following TABLE clause writer.keyword(getName()); call.operand(0).unparse(writer, 0, 0); } else { SqlUtil.unparseFunctionSyntax(this, writer, call); } } }
public SqlValidatorNamespace getNamespace(SqlNode node) { switch (node.getKind()) { case AS: // AS has a namespace if it has a column list 'AS t (c1, c2, ...)' final SqlValidatorNamespace ns = namespaces.get(node); if (ns != null) { return ns; } // fall through case OVER: case COLLECTION_TABLE: case ORDER_BY: case TABLESAMPLE: return getNamespace(((SqlCall) node).operand(0)); default: return namespaces.get(node); } }
public boolean isAggregate(SqlSelect select) { if (getAggregate(select) != null) { return true; } // Also when nested window aggregates are present for (SqlCall call : overFinder.findAll(select.getSelectList())) { assert call.getKind() == SqlKind.OVER; if (isNestedAggregateWindow(call.operand(0))) { return true; } if (isOverAggregateWindow(call.operand(1))) { return true; } } return false; }
/** * 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); }
case AS: validateFrom( ((SqlCall) node).operand(0), targetRowType, scope);
for (SqlNode row : values) { final SqlCall call = (SqlCall) row; final SqlNode sourceValue = call.operand(targetField.getIndex()); final ValidationError validationError = new ValidationError(sourceValue,
/** * 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); }
if (skipTo instanceof SqlCall) { final SqlCall skipToCall = (SqlCall) skipTo; final SqlIdentifier id = skipToCall.operand(0); if (!scope.getPatternVars().contains(id.getSimple())) { throw newValidationError(id,
final SqlNodeList selectList = new SqlNodeList(SqlParserPos.ZERO); selectList.add(SqlIdentifier.star(SqlParserPos.ZERO)); return new SqlSelect(SqlParserPos.ZERO, null, selectList, call.operand(0), null, null, null, null, null, null, null);
SqlCall rowCall = valuesCall.operand(0); selectList = new SqlNodeList(
@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); }
private SqlNode stripDot(SqlNode node) { if (node != null && node.getKind() == SqlKind.DOT) { return stripDot(((SqlCall) node).operand(0)); } return node; }