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

Skip the test for spark versions 3.1.1, 3.1.2 and 3.2.0 only [databricks] #4491

Merged
merged 3 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions integration_tests/src/main/python/cast_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from asserts import assert_gpu_and_cpu_are_equal_collect, assert_gpu_and_cpu_are_equal_sql, assert_gpu_and_cpu_error, assert_gpu_fallback_collect, assert_py4j_exception
from data_gen import *
from spark_session import is_before_spark_311, is_before_spark_320, is_before_spark_330, with_gpu_session
from spark_session import is_before_spark_320, with_gpu_session, is_neg_dec_scale_bug_version
from marks import allow_non_gpu, approximate_float
from pyspark.sql.types import *

Expand Down Expand Up @@ -301,7 +301,7 @@ def test_cast_struct_with_unsupported_element_to_string_fallback(data_gen, legac
"spark.sql.legacy.allowNegativeScaleOfDecimal": 'true'}
)

@pytest.mark.skipif(not is_before_spark_311() and is_before_spark_330(), reason="RAPIDS doesn't support casting string to decimal for negative scale decimal in this version of Spark because of SPARK-37451")
@pytest.mark.skipif(is_neg_dec_scale_bug_version(), reason="RAPIDS doesn't support casting string to decimal for negative scale decimal in this version of Spark because of SPARK-37451")
def test_cast_string_to_negative_scale_decimal():
assert_gpu_and_cpu_are_equal_collect(
lambda spark: unary_op_df(spark, StringGen("[0-9]{9}")).select(
Expand Down
6 changes: 5 additions & 1 deletion integration_tests/src/main/python/spark_session.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
# Copyright (c) 2020-2022, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -111,6 +111,10 @@ def is_before_spark_320():
def is_before_spark_330():
return spark_version() < "3.3.0"

# The bug SPARK-37451 only affects the following versions
def is_neg_dec_scale_bug_version():
jlowe marked this conversation as resolved.
Show resolved Hide resolved
return ("3.1.1" <= spark_version() < "3.1.3") or ("3.2.0" <= spark_version() < "3.2.1")
tgravescs marked this conversation as resolved.
Show resolved Hide resolved

def is_databricks91_or_later():
spark = get_spark_i_know_what_i_am_doing()
return spark.conf.get("spark.databricks.clusterUsageTags.sparkVersion", "") >= "9.1"
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ class Spark313Shims extends Spark31XShims with Spark30Xuntil33XShims {

override def hasCastFloatTimestampUpcast: Boolean = true

override def isCastingStringToNegDecimalScaleSupported: Boolean = true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, NVIDIA CORPORATION.
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,4 +37,6 @@ class Spark320Shims extends Spark320until322Shims with Spark30Xuntil33XShims {
metadataColumns: Seq[AttributeReference]): RDD[InternalRow] = {
new FileScanRDD(sparkSession, readFunction, filePartitions)
}

override def isCastingStringToNegDecimalScaleSupported: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,4 @@ class Spark322Shims extends Spark322PlusShims with Spark30Xuntil33XShims {
metadataColumns: Seq[AttributeReference]): RDD[InternalRow] = {
new FileScanRDD(sparkSession, readFunction, filePartitions)
}

override def isCastingStringToNegDecimalScaleSupported: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,6 @@ abstract class Spark30XShims extends Spark301until320Shims with Logging {
adaptivePlan.initialPlan
}

override def isCastingStringToNegDecimalScaleSupported: Boolean = true

// this is to help with an optimization in Spark 3.1, so we disable it by default in Spark 3.0.x
override def isEmptyRelation(relation: Any): Boolean = false
override def tryTransformIfEmptyRelation(mode: BroadcastMode): Option[Any] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ trait Spark31XdbShimsBase extends SparkShims {

override def shouldFallbackOnAnsiTimestamp(): Boolean = false

override def isCastingStringToNegDecimalScaleSupported: Boolean = true
override def isCastingStringToNegDecimalScaleSupported: Boolean = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does seem a bit dangerous in the sense if we add a databricks 3.1.3 shim we could easily miss this.
perhaps at least put a comment here. I assume the test won't fail if we get it wrong?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test isn't skipped for 3.1.3, it will blow up saying part of the plan isn't columnar as there is a check in GpuCast for it if we forget to override it for Spark-3.1.3-db.

I can move this to Spark312dbShims.

}
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,6 @@ trait Spark320PlusShims extends SparkShims with RebaseShims with Logging {
adaptivePlan.initialPlan
}

override def isCastingStringToNegDecimalScaleSupported: Boolean = false

override def columnarAdaptivePlan(a: AdaptiveSparkPlanExec,
goal: CoalesceSizeGoal): SparkPlan = {
a.copy(supportsColumnar = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ trait SparkShims {
def int96ParquetRebaseWrite(conf: SQLConf): String
def int96ParquetRebaseReadKey: String
def int96ParquetRebaseWriteKey: String
def isCastingStringToNegDecimalScaleSupported: Boolean
def isCastingStringToNegDecimalScaleSupported: Boolean = true

def getParquetFilters(
schema: MessageType,
Expand Down