-
Notifications
You must be signed in to change notification settings - Fork 288
Remove old Spark 4 shim sources and update tests #15038
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,12 +22,40 @@ package com.nvidia.spark.rapids.shims | |
|
|
||
| import com.nvidia.spark.rapids._ | ||
|
|
||
| import org.apache.spark.sql.catalyst.expressions.Expression | ||
| import org.apache.spark.sql.catalyst.expressions.{Expression, TimestampAddInterval} | ||
| import org.apache.spark.sql.rapids.shims.GpuTimestampAddInterval | ||
| import org.apache.spark.sql.types.{CalendarIntervalType, DayTimeIntervalType} | ||
| import org.apache.spark.unsafe.types.CalendarInterval | ||
|
|
||
| /** | ||
| * Empty TimeAddShims for Spark 4.1.0+ and Databricks 17.3. | ||
| * TimeAdd was renamed to TimestampAddInterval and is handled by DayTimeIntervalShims. | ||
| * TimestampAddInterval support for Spark 4.1.0+ and Databricks 17.3. | ||
| * TimeAdd was renamed to TimestampAddInterval in Spark 4.1. | ||
| */ | ||
| object TimeAddShims { | ||
| val exprs: Map[Class[_ <: Expression], ExprRule[_ <: Expression]] = Map.empty | ||
| val exprs: Map[Class[_ <: Expression], ExprRule[_ <: Expression]] = Seq( | ||
| GpuOverrides.expr[TimestampAddInterval]( | ||
| "Adds interval to timestamp", | ||
| ExprChecks.binaryProject(TypeSig.TIMESTAMP, TypeSig.TIMESTAMP, | ||
| ("start", TypeSig.TIMESTAMP, TypeSig.TIMESTAMP), | ||
| ("interval", TypeSig.DAYTIME + TypeSig.lit(TypeEnum.CALENDAR) | ||
| .withPsNote(TypeEnum.CALENDAR, "month intervals are not supported"), | ||
| TypeSig.DAYTIME + TypeSig.CALENDAR)), | ||
|
Comment on lines
+38
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| (timeAdd, conf, p, r) => new BinaryExprMeta[TimestampAddInterval](timeAdd, conf, p, r) { | ||
| override def tagExprForGpu(): Unit = { | ||
| GpuOverrides.extractLit(timeAdd.interval).foreach { lit => | ||
| lit.dataType match { | ||
| case CalendarIntervalType => | ||
| val intvl = lit.value.asInstanceOf[CalendarInterval] | ||
| if (intvl.months != 0) { | ||
| willNotWorkOnGpu("interval months isn't supported") | ||
| } | ||
| case _: DayTimeIntervalType => | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override def convertToGpu(lhs: Expression, rhs: Expression): GpuExpression = | ||
| GpuTimestampAddInterval(lhs, rhs) | ||
| }) | ||
| ).map(r => (r.getClassFor.asSubclass(classOf[Expression]), r)).toMap | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TimestampNTZTypecase injsonFieldsGpuLiteralShim.jsonFieldshandlesTimestampType(LTZ) viaDateTimeUtils.toJavaTimestamp, butTimestampNTZTypefalls through to the catch-allotherbranch, which calls.toStringon the rawLongmicrosecond value. AnyGpuLiteralwith aTIMESTAMP_NTZtype will therefore serialize as a bare integer in explain plans and plan JSON output rather than a human-readable timestamp string. The parallel path forDateTypealready shows the expected pattern —TIMESTAMP_NTZwould need something likeDateTimeUtils.microsToLocalDateTimeinstead oftoJavaTimestamp(which would incorrectly apply a timezone offset).