@Override public Boolean visitBooleanOperator(BooleanOperator op, ErrorCollector errors) { for (LogicalExpression e : op.args) { if (!e.accept(this, errors)) { return false; } } return true; }
/** * @param input * @param pos */ public AnyValueExpression(LogicalExpression input, ExpressionPosition pos) { super(pos); this.input = input; this.type = input.getMajorType(); }
public int compare(LogicalExpression e1, LogicalExpression e2) { return e1.getCumulativeCost() <= e2.getCumulativeCost() ? -1 : 1; } };
@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 Boolean visitFunctionHolderExpression(FunctionHolderExpression holder, ErrorCollector errors) { if (holder.isAggregating()) { for (int i = 0; i < holder.args.size(); i++) { LogicalExpression e = holder.args.get(i); if(e.accept(this, errors)) { errors.addGeneralError(e.getPosition(), String.format("Aggregating function call %s includes nested aggregations at arguments number %d. " + "This isn't allowed.", holder.getName(), i)); } } return true; } else { for (LogicalExpression e : holder.args) { if (e.accept(this, errors)) { return true; } } return false; } }
private ParquetComparisonPredicate( LogicalExpression left, LogicalExpression right, BiFunction<Statistics<C>, Statistics<C>, RowsMatch> predicate ) { super(left.getPosition()); this.left = left; this.right = right; this.predicate = predicate; }
/** * Defines function return type and sets precision if it pad length parameter is int expression. * If pad length is less than zero, return type precision is 0. * * @param logicalExpressions logical expressions * @param attributes function attributes * @return return type */ @Override public TypeProtos.MajorType getType(List<LogicalExpression> logicalExpressions, FunctionAttributes attributes) { TypeProtos.MajorType.Builder builder = TypeProtos.MajorType.newBuilder() .setMinorType(attributes.getReturnValue().getType().getMinorType()) .setMode(FunctionUtils.getReturnTypeDataMode(logicalExpressions, attributes)); if (logicalExpressions.get(1).iterator().hasNext() && logicalExpressions.get(1).iterator().next() instanceof ValueExpressions.IntExpression) { int precision = ((ValueExpressions.IntExpression) logicalExpressions.get(1).iterator().next()).getInt(); // if pad length is less than zero, output length is 0 builder.setPrecision(Math.max(precision, 0)); } return builder.build(); } }
@Override public Boolean visitFunctionHolderExpression(FunctionHolderExpression holder, ErrorCollector errors) { boolean allArgsAreConstant = true; for (int i = 0; i < holder.args.size(); i++) { boolean thisArgIsConstant = holder.args.get(i).accept(this, errors); if (!thisArgIsConstant) { allArgsAreConstant = false; if (holder.argConstantOnly(i)) { errors.addGeneralError( // holder.args.get(i).getPosition(), // String.format("Function %s expects constant input for argument number %d", holder.getName(), i)); } } } return allArgsAreConstant; }
MajorType majorType = cond.condition.getMajorType(); if ( majorType .getMinorType() != MinorType.BIT) { errors .addGeneralError( cond.condition.getPosition(), String .format( final MajorType mt = ifExpr.elseExpression.getMajorType(); cond = ifExpr.ifCondition; MajorType innerT = cond.expression.getMajorType(); if ((innerT.getMode() == DataMode.REPEATED && mt.getMode() != DataMode.REPEATED) || // ((innerT.getMinorType() != mt.getMinorType()) && errors .addGeneralError( cond.condition.getPosition(), String .format(
private ParquetIsPredicate(LogicalExpression expr, BiFunction<Statistics<C>, RangeExprEvaluator<C>, RowsMatch> predicate) { super(expr.getPosition()); this.expr = expr; this.predicate = predicate; }
@Override public Boolean visitBooleanOperator(BooleanOperator op, ErrorCollector errors) { for (LogicalExpression arg : op.args) { if (arg.accept(this, errors)) { return true; } } return false; }
@Override public MajorType getOutputType(List<LogicalExpression> expressions) { return expressions.get(0).getMajorType(); } }
@Override public Boolean visitFunctionHolderExpression(FunctionHolderExpression holder, ErrorCollector errors) { if (holder.isAggregating()) { for (int i = 0; i < holder.args.size(); i++) { LogicalExpression e = holder.args.get(i); if(e.accept(this, errors)) { errors.addGeneralError(e.getPosition(), String.format("Aggregating function call %s includes nested aggregations at arguments number %d. " + "This isn't allowed.", holder.getName(), i)); } } return true; } else { for (LogicalExpression e : holder.args) { if (e.accept(this, errors)) { return true; } } return false; } }
@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 int getCumulativeCost() { // return the average cost of operands for a boolean "and" | "or" int cost = this.getSelfCost(); int i = 0; for (LogicalExpression e : this) { cost += e.getCumulativeCost(); i++; } return cost / i; }
@Override public MajorType getOutputType(List<LogicalExpression> expressions) { for(LogicalExpression e : expressions){ if(e.getMajorType().getMode() == DataMode.OPTIONAL){ return e.getMajorType(); } } return expressions.get(0).getMajorType(); } }
@Override public Boolean visitFunctionHolderExpression(FunctionHolderExpression holder, ErrorCollector errors) { boolean allArgsAreConstant = true; for (int i = 0; i < holder.args.size(); i++) { boolean thisArgIsConstant = holder.args.get(i).accept(this, errors); if (!thisArgIsConstant) { allArgsAreConstant = false; if (holder.argConstantOnly(i)) { errors.addGeneralError( // holder.args.get(i).getPosition(), // String.format("Function %s expects constant input for argument number %d", holder.getName(), i)); } } } return allArgsAreConstant; }
MajorType majorType = cond.condition.getMajorType(); if ( majorType .getMinorType() != MinorType.BIT) { errors .addGeneralError( cond.condition.getPosition(), String .format( final MajorType mt = ifExpr.elseExpression.getMajorType(); cond = ifExpr.ifCondition; MajorType innerT = cond.expression.getMajorType(); if ((innerT.getMode() == DataMode.REPEATED && mt.getMode() != DataMode.REPEATED) || // ((innerT.getMinorType() != mt.getMinorType()) && errors .addGeneralError( cond.condition.getPosition(), String .format(
@Override public int getCumulativeCost() { // return the average cost of operands for a boolean "and" | "or" int cost = this.getSelfCost(); int i = 0; for (LogicalExpression e : this) { cost += e.getCumulativeCost(); i++; } return cost / i; }