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

Fall back to CPU for non-UTC months_between #11802

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions integration_tests/src/main/python/date_time_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,34 +139,34 @@ def test_datediff(data_gen):

hms_fallback = ['ProjectExec'] if not is_supported_time_zone() else []

@allow_non_gpu(*hms_fallback)
@allow_non_gpu(*non_utc_tz_allow)
def test_months_between():
assert_gpu_and_cpu_are_equal_collect(
lambda spark : binary_op_df(spark, timestamp_gen).selectExpr('months_between(a, b, false)'))

@allow_non_gpu(*hms_fallback)
@allow_non_gpu(*non_utc_tz_allow)
def test_months_between_first_day():
assert_gpu_and_cpu_are_equal_collect(
lambda spark : unary_op_df(spark, timestamp_gen).selectExpr('months_between(a, timestamp"2024-01-01", false)'))

@allow_non_gpu(*hms_fallback)
@allow_non_gpu(*non_utc_tz_allow)
def test_months_between_last_day():
assert_gpu_and_cpu_are_equal_collect(
lambda spark : unary_op_df(spark, timestamp_gen).selectExpr('months_between(a, timestamp"2023-12-31", false)'))

@allow_non_gpu(*hms_fallback)
@allow_non_gpu(*non_utc_tz_allow)
@approximate_float()
def test_months_between_round():
assert_gpu_and_cpu_are_equal_collect(
lambda spark : binary_op_df(spark, timestamp_gen).selectExpr('months_between(a, b, true)'))

@allow_non_gpu(*hms_fallback)
@allow_non_gpu(*non_utc_tz_allow)
@approximate_float()
def test_months_between_first_day_round():
assert_gpu_and_cpu_are_equal_collect(
lambda spark : unary_op_df(spark, timestamp_gen).selectExpr('months_between(a, timestamp"2024-01-01", true)'))

@allow_non_gpu(*hms_fallback)
@allow_non_gpu(*non_utc_tz_allow)
@approximate_float()
def test_months_between_last_day_round():
assert_gpu_and_cpu_are_equal_collect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,8 @@ class MonthsBetweenExprMeta(expr: MonthsBetween,
rule: DataFromReplacementRule)
extends ExprMeta[MonthsBetween](expr, conf, parent, rule) {

override def isTimeZoneSupported = true
// See https://github.com/NVIDIA/spark-rapids/issues/11800
override def isTimeZoneSupported = false

override def convertToGpu(): GpuExpression = {
val gpuChildren = childExprs.map(_.convertToGpu())
Expand Down Expand Up @@ -1287,6 +1288,13 @@ object GpuMonthsBetween {
private def calcSecondsInDay(converted: ColumnVector): ColumnVector = {
// Find the number of seconds that are not counted for in a day

// Rounding down to the current day, only works if you are in a time zone with no
// transition rules. This is because if a transition happens in between the start
// of the day and the timestamp we will be off. As such this will need to change to
// support other time zones, and it will need to take the timezone into account when
// calculating this.
// https://github.com/NVIDIA/spark-rapids/issues/11800

// find the micros over by finding the part that is not days
val microsInDay = withResource(converted.dateTimeFloor(DateTimeRoundingFrequency.DAY)) { days =>
// But we cannot subtract timestamps directly. They are both micros
Expand Down
Loading