Skip to content

Commit

Permalink
Add CastOptions to make GpuCast extendible to handle more options [da…
Browse files Browse the repository at this point in the history
…tabricks] (#9285)

* Refactored GpuCast to take a CastOptions to make it easer to pass in options

* singing off

---------

Signed-off-by: Raza Jafri <[email protected]>
  • Loading branch information
razajafri authored Sep 23, 2023
1 parent f68cb94 commit 056c187
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.NoSuchElementException;

import ai.rapids.cudf.Scalar;
import com.nvidia.spark.rapids.CastOptions$;
import com.nvidia.spark.rapids.GpuCast;
import com.nvidia.spark.rapids.GpuColumnVector;
import com.nvidia.spark.rapids.GpuScalar;
Expand Down Expand Up @@ -158,7 +159,7 @@ static ColumnarBatch addUpcastsIfNeeded(ColumnarBatch batch, Schema expectedSche
GpuColumnVector oldColumn = columns[i];
columns[i] = GpuColumnVector.from(
GpuCast.doCast(oldColumn.getBase(), oldColumn.dataType(), expectedSparkType,
false, false, false), expectedSparkType);
CastOptions$.MODULE$.DEFAULT_CAST_OPTIONS()), expectedSparkType);
}
ColumnarBatch newBatch = new ColumnarBatch(columns, batch.numRows());
columns = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ case class ApproxPercentileFromTDigestExpr(
// array and return that (after converting from Double to finalDataType)
withResource(cv.getBase.approxPercentile(Array(p))) { percentiles =>
withResource(percentiles.extractListElement(0)) { childView =>
withResource(doCast(childView, DataTypes.DoubleType, finalDataType,
ansiMode = false, legacyCastToString = false,
stringToDateAnsiModeEnabled = false)) { childCv =>
withResource(doCast(childView, DataTypes.DoubleType, finalDataType)) { childCv =>
GpuColumnVector.from(childCv.copyToColumnVector(), dataType)
}
}
Expand All @@ -159,9 +157,7 @@ case class ApproxPercentileFromTDigestExpr(
GpuColumnVector.from(percentiles.incRefCount(), dataType)
} else {
withResource(percentiles.getChildColumnView(0)) { childView =>
withResource(doCast(childView, DataTypes.DoubleType, finalDataType,
ansiMode = false, legacyCastToString = false,
stringToDateAnsiModeEnabled = false)) { childCv =>
withResource(doCast(childView, DataTypes.DoubleType, finalDataType)) { childCv =>
withResource(percentiles.replaceListChild(childCv)) { x =>
GpuColumnVector.from(x.copyToColumnVector(), dataType)
}
Expand Down
Loading

0 comments on commit 056c187

Please sign in to comment.