@Override public LogicalExpression visitBooleanOperator(BooleanOperator op, Void value) throws RuntimeException { List<LogicalExpression> newArgs = Lists.newArrayList(); newArgs.addAll(op.args); Collections.sort(newArgs, costComparator); return new BooleanOperator(op.getName(), newArgs, op.getPosition()); }
@Override public Void visitBooleanOperator(BooleanOperator op, ErrorCollector errors) throws RuntimeException { int i = 0; for (LogicalExpression arg : op.args) { if ( arg.getMajorType().getMinorType() != MinorType.BIT) { errors .addGeneralError( arg.getPosition(), String .format( "Failure composing boolean operator %s. All conditions must return a boolean type. Condition %d was of Type %s.", op.getName(), i, arg.getMajorType().getMinorType())); } i++; } return null; }
@Override public ValueHolder visitBooleanOperator(BooleanOperator op, Integer inIndex) { // Apply short circuit evaluation to boolean operator. if (op.getName().equals("booleanAnd")) { return visitBooleanAnd(op, inIndex); }else if(op.getName().equals("booleanOr")) { return visitBooleanOr(op, inIndex); } else { throw new UnsupportedOperationException("BooleanOperator can only be booleanAnd, booleanOr. You are using " + op.getName()); } }
@Override public HoldingContainer visitBooleanOperator(BooleanOperator op, ClassGenerator<?> generator) throws RuntimeException { if (op.getName().equals("booleanAnd")) { return visitBooleanAnd(op, generator); } else if(op.getName().equals("booleanOr")) { return visitBooleanOr(op, generator); } else { throw new UnsupportedOperationException("BooleanOperator can only be booleanAnd, booleanOr. You are using " + op.getName()); } }
@Override public LogicalExpression visitBooleanOperator(BooleanOperator op, Void value) throws RuntimeException { List<LogicalExpression> newArgs = Lists.newArrayList(); newArgs.addAll(op.args); Collections.sort(newArgs, costComparator); return new BooleanOperator(op.getName(), newArgs, op.getPosition()); }
@Override public LogicalExpression visitBooleanOperator(BooleanOperator op, Set<LogicalExpression> value) { List<LogicalExpression> childPredicates = new ArrayList<>(); String functionName = op.getName(); for (LogicalExpression arg : op.args) { LogicalExpression childPredicate = arg.accept(this, value); if (childPredicate == null) { if (functionName.equals("booleanOr") || !omitUnsupportedExprs) { // we can't include any leg of the OR if any of the predicates cannot be converted // or prohibited omitting of unconverted operands return null; } } else { if (childPredicate instanceof TypedFieldExpr) { // Calcite simplifies `= true` expression to field name, wrap it with is true predicate childPredicate = ParquetIsPredicate.createIsPredicate(FunctionGenerationHelper.IS_TRUE, childPredicate); } childPredicates.add(childPredicate); } } if (childPredicates.size() == 0) { return null; // none leg is qualified, return null. } else if (childPredicates.size() == 1) { return childPredicates.get(0); // only one leg is qualified, remove boolean op. } else { return ParquetBooleanPredicate.createBooleanPredicate(functionName, op.getName(), childPredicates, op.getPosition()); } }
@Override public LogicalExpression visitBooleanOperator(BooleanOperator op, FunctionLookupContext functionLookupContext) { List<LogicalExpression> args = Lists.newArrayList(); for (int i = 0; i < op.args.size(); ++i) { LogicalExpression newExpr = op.args.get(i).accept(this, functionLookupContext); assert newExpr != null : String.format("Materialization of %s return a null expression.", op.args.get(i)); args.add(newExpr); } //replace with a new function call, since its argument could be changed. return new BooleanOperator(op.getName(), args, op.getPosition()); }
@Override public Void visitBooleanOperator(BooleanOperator op, ErrorCollector errors) throws RuntimeException { int i = 0; for (LogicalExpression arg : op.args) { if ( arg.getMajorType().getMinorType() != MinorType.BIT) { errors .addGeneralError( arg.getPosition(), String .format( "Failure composing boolean operator %s. All conditions must return a boolean type. Condition %d was of Type %s.", op.getName(), i, arg.getMajorType().getMinorType())); } i++; } return null; }