Skip to content

Commit

Permalink
Remove istrue, isfalse vectorized impls. (#14991)
Browse files Browse the repository at this point in the history
These were added in #14977, but the implementations are incorrect, because they return null when the input arg is null. They should return false when the input is null. Remove them for now, rather than fixing them, since they're so new that they might as well never have existed.
  • Loading branch information
gianm authored Sep 25, 2023
1 parent c184b52 commit 0850e61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
27 changes: 0 additions & 27 deletions processing/src/main/java/org/apache/druid/math/expr/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.druid.java.util.common.UOE;
import org.apache.druid.math.expr.vector.CastToTypeVectorProcessor;
import org.apache.druid.math.expr.vector.ExprVectorProcessor;
import org.apache.druid.math.expr.vector.VectorComparisonProcessors;
import org.apache.druid.math.expr.vector.VectorMathProcessors;
import org.apache.druid.math.expr.vector.VectorProcessors;
import org.apache.druid.math.expr.vector.VectorStringProcessors;
Expand Down Expand Up @@ -2422,19 +2421,6 @@ public ExpressionType getOutputType(Expr.InputBindingInspector inspector, List<E
{
return ExpressionType.LONG;
}

@Override
public boolean canVectorize(Expr.InputBindingInspector inspector, List<Expr> args)
{
final Expr expr = args.get(0);
return inspector.areNumeric(expr) && expr.canVectorize(inspector);
}

@Override
public <T> ExprVectorProcessor<T> asVectorProcessor(Expr.VectorInputBindingInspector inspector, List<Expr> args)
{
return VectorComparisonProcessors.lessThanOrEqual(inspector, args.get(0), ExprEval.of(0L).toExpr());
}
}

/**
Expand Down Expand Up @@ -2467,19 +2453,6 @@ public ExpressionType getOutputType(Expr.InputBindingInspector inspector, List<E
{
return ExpressionType.LONG;
}

@Override
public boolean canVectorize(Expr.InputBindingInspector inspector, List<Expr> args)
{
final Expr expr = args.get(0);
return inspector.areNumeric(expr) && expr.canVectorize(inspector);
}

@Override
public <T> ExprVectorProcessor<T> asVectorProcessor(Expr.VectorInputBindingInspector inspector, List<Expr> args)
{
return VectorComparisonProcessors.greaterThan(inspector, args.get(0), ExprEval.of(0L).toExpr());
}
}

class IsNullFunc implements Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2470,6 +2470,12 @@ public void testExactCountDistinctWithFilter()
);

requireMergeBuffers(3);

if (NullHandling.sqlCompatible()) {
// Cannot vectorize due to "istrue" operator.
cannotVectorize();
}

testQuery(
PLANNER_CONFIG_NO_HLL.withOverrides(
ImmutableMap.of(
Expand All @@ -2489,9 +2495,9 @@ public void testExactCountDistinctWithFilter()
.setGranularity(Granularities.ALL)
.setVirtualColumns(expressionVirtualColumn(
"v0",
NullHandling.replaceWithDefault()
? "(\"cnt\" == 1)"
: "istrue((\"cnt\" == 1))",
NullHandling.sqlCompatible()
? "istrue((\"cnt\" == 1))"
: "(\"cnt\" == 1)",
ColumnType.LONG
))
.setDimensions(dimensions(
Expand Down

0 comments on commit 0850e61

Please sign in to comment.