Refine search
@Override public TupleExpression visitCall(RexCall call) { SqlOperator op = call.getOperator(); if (op instanceof SqlCastFunction) { return call.getOperands().get(0).accept(this); } else if (op instanceof SqlUserDefinedFunction) { if (op.getName().equals("QUARTER")) { return visitFirstRexInputRef(call); switch (op.getKind()) { case PLUS: tupleExpression = getBinaryTupleExpression(call, TupleExpression.ExpressionOperatorEnum.PLUS);
@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 void validateCall( SqlCall call, SqlValidatorScope scope) { final SqlOperator operator = call.getOperator(); if ((call.operandCount() == 0) && (operator.getSyntax() == SqlSyntax.FUNCTION_ID) && !call.isExpanded() && !conformance.allowNiladicParentheses()) { // For example, "LOCALTIME()" is illegal. (It should be // "LOCALTIME", which would have been handled as a // SqlIdentifier.) throw handleUnresolvedFunction(call, (SqlFunction) operator, ImmutableList.of(), null); } SqlValidatorScope operandScope = scope.getOperandScope(call); if (operator instanceof SqlFunction && ((SqlFunction) operator).getFunctionType() == SqlFunctionCategory.MATCH_RECOGNIZE && !(operandScope instanceof MatchRecognizeScope)) { throw newValidationError(call, Static.RESOURCE.functionMatchRecognizeOnly(call.toString())); } // Delegate validation to the operator. operator.validateCall(call, this, scope, operandScope); }
@Override public Void visitCall(org.apache.calcite.rex.RexCall call) { // non-deterministic functions as well as runtime constants are not materializable. if (!call.getOperator().isDeterministic() || call.getOperator().isDynamicFunction()) { throw new Util.FoundOne(call); } return super.visitCall(call); } };
SqlIdentifier curOpId = new SqlIdentifier( op.getName(), pos); result.add( new SqlMonikerImpl( op.getName(), SqlMonikerType.FUNCTION)); } else { if ((op.getSyntax() == SqlSyntax.FUNCTION) || (op.getSyntax() == SqlSyntax.PREFIX)) { if (op.getOperandTypeChecker() != null) { String sig = op.getAllowedSignatures(); sig = sig.replaceAll("'", ""); result.add( op.getName(), SqlMonikerType.FUNCTION));
@Override public Boolean visitCall(RexCall call) { if (call.getOperator().getName().equalsIgnoreCase("contains")) { if (!checkOrigin) { return true; origins = mq.getColumnOrigins(node, index); } else { List<RelDataTypeField> fields = ImmutableList.<RelDataTypeField>of(new RelDataTypeFieldImpl("ContainsTemp", 0, call.getType())); Project temporary = new LogicalProject(node.getCluster(), node.getTraitSet().plus(Convention.NONE), node.getInput(0), ImmutableList.of(call), new RelRecordType(fields)); origins = mq.getColumnOrigins(temporary, 0); for (RexNode op : call.getOperands()) { Boolean opResult = op.accept(this); if (opResult != null && opResult.booleanValue()) { return true;
@Override public RexNode visitCall(RexCall call) { SqlOperator op = call.getOperator(); SqlKind kind = op.getKind(); RelDataType type = call.getType(); if (kind == SqlKind.OR || kind == SqlKind.AND) { if (call.getOperands().size() > 2) { List<RexNode> children = new ArrayList<>(call.getOperands()); RexNode left = children.remove(0).accept(this); RexNode right = builder.makeCall(type, op, children).accept(this); return builder.makeCall(type, op, ImmutableList.of(left, right)); } } return builder.makeCall(type, op, visitChildren(call)); }
@Override public RexNode visitCall(final RexCall call) { final String functionName = call.getOperator().getName(); final List<RexNode> clonedOperands = visitList(call.getOperands(), update); if (op.getOperandTypeChecker().getOperandCountRange().isValidCount(nArgs - 1)) { newFunction = (SqlFunction) op; break; } else { return builder.makeCall(sqlOperator, ImmutableList.of(clonedOperands.get(0), clonedOperands.get(2)));
Builder<RelDataType> argTypeBldr = ImmutableList.<RelDataType> builder(); SqlOperator calciteOp = SqlFunctionConverter.getCalciteOperator(func.getFuncText(), func.getGenericUDF(), argTypeBldr.build(), retType); if (calciteOp.getKind() == SqlKind.CASE) { } else if (calciteOp.getKind() == SqlKind.IN && isAllPrimitive) { if (childRexNodeLst.size() == 2) { calciteOp = SqlStdOperatorTable.OR; } else if (calciteOp.getKind() == SqlKind.COALESCE && childRexNodeLst.size() > 1 ) { retType = expr.getType(); && !(((RexCall) expr).getOperator() instanceof SqlCastFunction)) { RexCall call = (RexCall) expr; expr = cluster.getRexBuilder().makeCall(retType, call.getOperator(), RexUtil.flatten(call.getOperands(), call.getOperator()));
protected String computeDigest(boolean withType) { StringBuilder sb = new StringBuilder(op.getName()); if ((operands.size() == 0) && (op.getSyntax() == SqlSyntax.FUNCTION_ID)) { // Don't print params for empty arg list. For example, we want // "SYSTEM_USER", not "SYSTEM_USER()". } else { sb.append("("); for (int i = 0; i < operands.size(); i++) { if (i > 0) { sb.append(", "); } RexNode operand = operands.get(i); sb.append(operand.toString()); } sb.append(")"); } if (withType) { sb.append(":"); // NOTE jvs 16-Jan-2005: for digests, it is very important // to use the full type string. sb.append(type.getFullTypeString()); } return sb.toString(); }
if (call.getKind() == SqlKind.EXTRACT) { args.add(call.operands.get(1).accept(this)); } else if (call.getKind() == SqlKind.FLOOR && call.operands.size() == 2) { args.add(call.operands.get(0).accept(this)); } else { for (RexNode operand : call.operands) { args.add(operand.accept(this)); if (call.isA(SqlKind.CAST) && (call.operands.size() == 1) && SqlTypeUtil.equalSansNullability(dTFactory, call.getType(), if (hiveUdf == null) { throw new RuntimeException("Cannot find UDF for " + call.getType() + " " + call.getOperator() + "[" + call.getOperator().getKind() + "]/" + args.size());
public static boolean isFlat(RexCall call) { boolean flat = false; if (call.operands != null && call.operands.size() > 2) { SqlOperator op = call.getOperator(); if (op.getKind() == SqlKind.AND || op.getKind() == SqlKind.OR) { flat = true; } } return flat; }
@Override public PathSegment visitCall(RexCall call) { if ("ITEM".equals(call.getOperator().getName())) { PathSegment mapOrArray = call.operands.get(0).accept(this); if (mapOrArray != null) { if (call.operands.get(1) instanceof RexLiteral) { return mapOrArray.cloneWithNewChild(convertLiteral((RexLiteral) call.operands.get(1))); } return mapOrArray; } } else { for (RexNode operand : call.operands) { addColumn(operand.accept(this)); } } return null; }
switch (conjCall.getOperator().getKind()) { case EQUALS: if (!(RexUtil.isConstant(conjCall.operands.get(0))) && RexUtil.isConstant(conjCall.operands.get(1))) { conditions.put(conjCall.operands.get(0).toString(), conjCall.operands.get(1)); } else if (!(RexUtil.isConstant(conjCall.operands.get(1))) && RexUtil.isConstant(conjCall.operands.get(0))) { conditions.put(conjCall.operands.get(1).toString(), conjCall.operands.get(0)); conditions.put(conjCall.operands.get(0).toString(), relBuilder.getRexBuilder().makeNullLiteral( conjCall.operands.get(0).getType().getSqlTypeName()));
@Override public RexNode visitCall(RexCall call) { if (COMPARISON.contains(call.getOperator().getKind())) { RexInputRef ref = null; RexLiteral literal = null; SqlKind kind = null; if (call.operands.get(0) instanceof RexInputRef && call.operands.get(1) instanceof RexLiteral) { ref = (RexInputRef) call.operands.get(0); literal = (RexLiteral) call.operands.get(1); kind = call.getOperator().getKind(); kind = call.getOperator().getKind().reverse(); } else if (call.getOperator().getKind() == SqlKind.IN) { RexNode reduced = reduceCall(literal, SqlKind.EQUALS, max, min); if (reduced != null) { if (reduced.isAlwaysTrue()) { return rexBuilder.makeLiteral(true); } else if (call.getOperands().get(0).getKind() == SqlKind.ROW) { } else if (call.getOperator().getKind() == SqlKind.IS_NULL || call.getOperator().getKind() == SqlKind.IS_NOT_NULL) { SqlKind kind = call.getOperator().getKind();
@Override public Boolean visitCall(RexCall call) { if (call.getKind() == SqlKind.NOT || call.getKind() == SqlKind.NOT_EQUALS || call.getKind() == SqlKind.NOT_IN) { directCompareOp = true; contextCall = call; boolean markIt = operand.accept(this); directCompareOp = false; contextCall = null; if ("ITEM".equals(call.getOperator().getName())) { return directCompareOp; RexNode castOp = call.operands.get(0); if (castOp instanceof RexInputRef) { return true; if ((castOp instanceof RexCall) && ("ITEM".equals(((RexCall)castOp).getOperator().getName()))) { return true; boolean bret = operand.accept(this);
/** * Interprets argument as a constraint; if not possible returns null. */ public static Constraint of(RexNode n) { if (!(n instanceof RexCall)) { return null; } RexCall call = (RexCall) n; if (call.getOperator().getKind() != SqlKind.EQUALS) { return null; } RexNode opA = call.operands.get(0); RexNode opB = call.operands.get(1); if (RexUtil.isNull(opA) || RexUtil.isNull(opB)) { // dont try to compare nulls return null; } if (isConstExpr(opA) && isColumnExpr(opB)) { return new Constraint(opB, opA); } if (isColumnExpr(opA) && isConstExpr(opB)) { return new Constraint(opA, opB); } return null; }