Refine search
private static boolean isThreeArgCase(final RexNode rexNode) { return rexNode.getKind() == SqlKind.CASE && ((RexCall) rexNode).getOperands().size() == 3; } }
private static RexTableInputRef extractTableInputRef(RexNode node) { RexTableInputRef ref = null; if (node instanceof RexTableInputRef) { ref = (RexTableInputRef) node; } else if (RexUtil.isLosslessCast(node) && ((RexCall) node).getOperands().get(0) instanceof RexTableInputRef) { ref = (RexTableInputRef) ((RexCall) node).getOperands().get(0); } return ref; }
private void flattenPredicates(RexNode r) { if (r instanceof RexCall && ((RexCall) r).getOperator() == SqlStdOperatorTable.AND) { for (RexNode c : ((RexCall) r).getOperands()) { flattenPredicates(c); } } else { pruningPredicates.add(r); } }
@Nullable @Override public String toDruidExpression(RexNode rexNode, RelDataType rowType, DruidQuery query ) { final RexCall call = (RexCall) rexNode; if (call.getOperands().size() != 1) { throw new IllegalStateException("to_date() requires 1 argument, got " + call.getOperands().size()); } final String arg = DruidExpressions.toDruidExpression(call.getOperands().get(0), rowType, query); if (arg == null) { return null; } return DruidExpressions.applyTimestampFloor( arg, Period.days(1).toString(), "", timezoneId(query, call.getOperands().get(0))); } }
@Override public RexNode visitCall(final RexCall call) { if(!valueGenerator) { if(call.getOperands().size() == 2) { final List<RexNode> operands = new ArrayList<>(call.operands); RexNode o0 = operands.get(0); RexNode o1 = operands.get(1); boolean isCorrelated = false; if (o0 instanceof RexFieldAccess && (cm.mapFieldAccessToCorRef.get(o0) != null)) { o0 = decorrFieldAccess((RexFieldAccess) o0); isCorrelated = true; } if (o1 instanceof RexFieldAccess && (cm.mapFieldAccessToCorRef.get(o1) != null)) { o1 = decorrFieldAccess((RexFieldAccess) o1); isCorrelated = true; } if (isCorrelated && RexUtil.eq(o0, o1)) { return rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL, o0); } final List<RexNode> newOperands = new ArrayList<>(); newOperands.add(o0); newOperands.add(o1); boolean[] update = {false}; List<RexNode> clonedOperands = visitList(newOperands, update); return relBuilder.call(call.getOperator(), clonedOperands); } } return super.visitCall(call); }
@Override public Void visitCall(RexCall call) { if (call.getOperator().getKind() == SqlKind.EQUALS) { int lPos = pos(call.getOperands().get(0)); int rPos = pos(call.getOperands().get(1)); if (lPos != -1 && rPos != -1) { JoinConditionBasedPredicateInference.this.equivalent(lPos, rPos); JoinConditionBasedPredicateInference.this.equalityPredicates .add(call.toString()); } } return null; } }
private RexNode convertLikeToRange(RexCall condition, RexBuilder builder) { Preconditions.checkArgument(condition.getOperator().getKind() == SqlKind.LIKE, "Unable to convertLikeToRange: argument is not a LIKE condition!"); HBaseRegexParser parser = null; RexLiteral pattern = null, escape = null; String patternStr = null, escapeStr = null; if (condition.getOperands().size() == 2) { for (RexNode op : condition.getOperands()) { if (op.getKind() == SqlKind.LITERAL) { pattern = (RexLiteral) op; parser = new HBaseRegexParser(patternStr); } else if (condition.getOperands().size() == 3) { for (RexNode op : condition.getOperands()) { if (op.getKind() == SqlKind.LITERAL) {
@Nullable @Override public String toDruidExpression(RexNode rexNode, RelDataType rowType, DruidQuery query ) { final RexCall call = (RexCall) rexNode; if (call.getOperands().size() < 1 || call.getOperands().size() > 2) { throw new IllegalStateException("form_unixtime() requires 1 or 2 argument, got " + call.getOperands().size()); } final String arg = DruidExpressions.toDruidExpression(call.getOperands().get(0), rowType, query); if (arg == null) { return null; } final String numMillis = DruidQuery.format("(%s * '1000')", arg); final String format = call.getOperands().size() == 1 ? DruidExpressions.stringLiteral(DEFAULT_TS_FORMAT) : DruidExpressions .toDruidExpression(call.getOperands().get(1), rowType, query); return DruidExpressions.functionCall("timestamp_format", ImmutableList.of(numMillis, format, DruidExpressions.stringLiteral(TimeZone.getTimeZone("UTC").getID())) ); } }
if (call.getOperands().get(0) instanceof RexInputRef) { RexInputRef ref = (RexInputRef) call.getOperands().get(0); for (int i = 1; i < call.getOperands().size(); i++) { RexNode operand = call.getOperands().get(i); if (operand instanceof RexLiteral) { RexLiteral literal = (RexLiteral) operand; if (newOperands.size() == 1) { return rexBuilder.makeLiteral(false); } else if (call.getOperands().get(0).getKind() == SqlKind.ROW) { RexCall struct = (RexCall) call.getOperands().get(0); List<RexInputRef> refs = Lists.newArrayList(); List<Pair<Number,Number>> maxMinStats = Lists.newArrayList(); for (RexNode operand: struct.getOperands()) { if (!(operand instanceof RexInputRef)) { for (int i = 1; i < call.getOperands().size(); i++) { RexCall constStruct = (RexCall) call.getOperands().get(i); boolean allTrue = true; boolean addOperand = true; for (int j = 0; j < constStruct.getOperands().size(); j++) { RexNode operand = constStruct.getOperands().get(j); if (operand instanceof RexLiteral) { RexLiteral literal = (RexLiteral) operand;
@Override public Void visitCall(RexCall call) { if (call.getOperator().getKind() == SqlKind.EQUALS) { int lPos = pos(call.getOperands().get(0)); int rPos = pos(call.getOperands().get(1)); if (lPos != -1 && rPos != -1) { JoinConditionBasedPredicateInference.this.equivalent(lPos, rPos); JoinConditionBasedPredicateInference.this.equalityPredicates .add(call.toString()); } } return null; } }
final RexLiteral flag = (RexLiteral) call.getOperands().get(0); final SqlTrimFunction.Flag trimStyle = (SqlTrimFunction.Flag) flag.getValue(); plannerContext, rowSignature, call.getOperands().get(1) ); plannerContext, rowSignature, call.getOperands().get(2) );
private RexCallTupleExpression getRexCallTupleExpression(RexCall call) { List<TupleExpression> children = Lists.newArrayListWithExpectedSize(call.getOperands().size()); for (RexNode rexNode : call.operands) { children.add(rexNode.accept(this)); } RexCallTupleExpression tuple = new RexCallTupleExpression(children); tuple.setDigest(call.toString()); return tuple; }
private void flattenPredicates(RexNode r) { if (r instanceof RexCall && ((RexCall) r).getOperator() == SqlStdOperatorTable.AND) { for (RexNode c : ((RexCall) r).getOperands()) { flattenPredicates(c); } } else { pruningPredicates.add(r); } }
public static CompareTupleFilter.CompareResultType getCompareResultType(RexCall whenCall) { List<RexNode> operands = whenCall.getOperands(); if (SqlKind.EQUALS == whenCall.getKind() && operands != null && operands.size() == 2) { if (operands.get(0).equals(operands.get(1))) { return CompareTupleFilter.CompareResultType.AlwaysTrue; } if (isConstant(operands.get(0)) && isConstant(operands.get(1))) { return CompareTupleFilter.CompareResultType.AlwaysFalse; } } return CompareTupleFilter.CompareResultType.Unknown; }
switch (e.getKind()) { case AND: for (RexNode operand : ((RexCall) e).getOperands()) { findCorrelationEquivalent(correlation, operand); final List<RexNode> operands = call.getOperands(); if(operands.size() == 2) { if (references(operands.get(0), correlation) && operands.get(1) instanceof RexInputRef) { return; throw new Util.FoundOne(Pair.of(((RexInputRef) operands.get(1)).getIndex(), Pair.of(((RexCall) e).getOperator(), true))); if (references(operands.get(1), correlation) throw new Util.FoundOne(Pair.of(((RexInputRef) operands.get(0)).getIndex(), Pair.of(((RexCall) e).getOperator(), false)));
private boolean isRexLiteral(final RexNode rexNode) { if(rexNode instanceof RexLiteral) { return true; } else if(rexNode instanceof RexCall && ((RexCall)rexNode).getOperator().getKind() == SqlKind.CAST){ return isRexLiteral(((RexCall)(rexNode)).getOperands().get(0)); } else { return false; } }
public static boolean isConstant(RexNode rexNode) { if (rexNode instanceof RexLiteral) { return true; } if (rexNode instanceof RexCall && SqlKind.CAST.equals(rexNode.getKind()) && ((RexCall) rexNode).getOperands().get(0) instanceof RexLiteral) { return true; } return false; } }
case AND: ImmutableList<RexNode> operands = RexUtil.flattenAnd(((RexCall) topFilterCondition) .getOperands()); Set<String> operandsToPushDownDigest = new HashSet<String>(); List<RexNode> extractedCommonOperands = null; if (nonDeterministicExprs.size() > 0) { for (RexNode expr : deterministicExprs) { if (!operandsToPushDownDigest.contains(expr.toString())) {
@Override public Boolean visitCall(RexCall call) { // Constant if operator is deterministic and all operands are // constant. return call.getOperator().isDeterministic() && RexVisitorImpl.visitArrayAnd(this, call.getOperands()); }
@Override public DruidExpression toDruidExpression( final PlannerContext plannerContext, final RowSignature rowSignature, final RexNode rexNode ) { final RexCall call = (RexCall) rexNode; final RexNode timeArg = call.getOperands().get(0); final DruidExpression timeExpression = Expressions.toDruidExpression(plannerContext, rowSignature, timeArg); if (timeExpression == null) { return null; } final TimestampExtractExprMacro.Unit unit = TimestampExtractExprMacro.Unit.valueOf( StringUtils.toUpperCase(RexLiteral.stringValue(call.getOperands().get(1))) ); final DateTimeZone timeZone = call.getOperands().size() > 2 && !RexLiteral.isNullLiteral(call.getOperands().get(2)) ? DateTimes.inferTzFromString(RexLiteral.stringValue(call.getOperands().get(2))) : plannerContext.getTimeZone(); return applyTimeExtract(timeExpression, unit, timeZone); } }