Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the null replacement in computePredicate #2486

Merged
merged 2 commits into from
May 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,13 @@ import org.apache.spark.sql.types.{BooleanType, DataType}
import org.apache.spark.sql.vectorized.ColumnarBatch

abstract class GpuConditionalExpression extends ComplexTypeMergingExpression with GpuExpression {
private def computePredicate(
batch: ColumnarBatch,
predicateExpr: Expression): GpuColumnVector = {
val predicate: Any = predicateExpr.columnarEval(batch)
try {
if (!predicate.isInstanceOf[GpuColumnVector]) {
throw new IllegalStateException("Predicate result is not a column")
}
val p = predicate.asInstanceOf[GpuColumnVector]

// TODO: This null replacement is no longer necessary when
// https://github.com/rapidsai/cudf/issues/3856 is fixed.
withResource(Scalar.fromBool(false)) { falseScalar =>
GpuColumnVector.from(p.getBase.replaceNulls(falseScalar), BooleanType)
}
} finally {
predicate match {
case c: AutoCloseable => c.close()
case _ =>
}
}
}

protected def computeIfElse(
batch: ColumnarBatch,
predicateExpr: Expression,
trueExpr: Expression,
falseValues: GpuColumnVector): GpuColumnVector = {
withResource(computePredicate(batch, predicateExpr)) { predicate =>
withResource(GpuExpressionsUtils.columnarEvalToColumn(predicateExpr, batch)) { predicate =>
val trueResult: Any = trueExpr.columnarEval(batch)
try {
val result = trueResult match {
Expand All @@ -77,7 +55,7 @@ abstract class GpuConditionalExpression extends ComplexTypeMergingExpression wit
predicateExpr: Expression,
trueExpr: Expression,
falseValue: Scalar): GpuColumnVector = {
withResource(computePredicate(batch, predicateExpr)) { predicate =>
withResource(GpuExpressionsUtils.columnarEvalToColumn(predicateExpr, batch)) { predicate =>
val trueResult: Any = trueExpr.columnarEval(batch)
try {
val result = trueResult match {
Expand Down