-
Notifications
You must be signed in to change notification settings - Fork 249
fix: Mark SortOrder with floating-point as incompatible #2650
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
Merged
+140
−30
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
72ae355
failing test
andygrove 19cadc6
make floating-point sort compatible with Spark:
andygrove 2def18f
fall back
andygrove 901866d
fix
andygrove 05a4de0
update
andygrove 7770465
format
andygrove 8f3cbc5
enable
andygrove 12bd291
fix
andygrove d2c7f94
tuning guide
andygrove 370793e
docs
andygrove 937d514
docs
andygrove 2ce637d
prep for review
andygrove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ import org.apache.spark.sql.internal.SQLConf.SESSION_LOCAL_TIMEZONE | |
| import org.apache.spark.sql.types._ | ||
|
|
||
| import org.apache.comet.CometSparkSessionExtensions.isSpark40Plus | ||
| import org.apache.comet.testing.{DataGenOptions, FuzzDataGenerator} | ||
|
|
||
| class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper { | ||
| import testImplicits._ | ||
|
|
@@ -60,6 +61,70 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper { | |
| val DIVIDE_BY_ZERO_EXCEPTION_MSG = | ||
| """Division by zero. Use `try_divide` to tolerate divisor being 0 and return NULL instead""" | ||
|
|
||
| test("sort floating point with negative zero") { | ||
| val schema = StructType( | ||
| Seq( | ||
| StructField("c0", DataTypes.FloatType, true), | ||
| StructField("c1", DataTypes.DoubleType, true))) | ||
| val df = FuzzDataGenerator.generateDataFrame( | ||
| new Random(42), | ||
| spark, | ||
| schema, | ||
| 1000, | ||
| DataGenOptions(generateNegativeZero = true)) | ||
| df.createOrReplaceTempView("tbl") | ||
|
|
||
| withSQLConf(CometConf.getExprAllowIncompatConfigKey("SortOrder") -> "false") { | ||
| checkSparkAnswerAndFallbackReason( | ||
| "select * from tbl order by 1, 2", | ||
| "unsupported range partitioning sort order") | ||
|
Member
Author
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. I filed a follow-up issue for improving the fallback reason to show the root cause |
||
| } | ||
| } | ||
|
|
||
| test("sort array of floating point with negative zero") { | ||
| val schema = StructType( | ||
| Seq( | ||
| StructField("c0", DataTypes.createArrayType(DataTypes.FloatType), true), | ||
| StructField("c1", DataTypes.createArrayType(DataTypes.DoubleType), true))) | ||
| val df = FuzzDataGenerator.generateDataFrame( | ||
| new Random(42), | ||
| spark, | ||
| schema, | ||
| 1000, | ||
| DataGenOptions(generateNegativeZero = true)) | ||
| df.createOrReplaceTempView("tbl") | ||
|
|
||
| withSQLConf(CometConf.getExprAllowIncompatConfigKey("SortOrder") -> "false") { | ||
| checkSparkAnswerAndFallbackReason( | ||
| "select * from tbl order by 1, 2", | ||
| "unsupported range partitioning sort order") | ||
| } | ||
| } | ||
|
|
||
| test("sort struct containing floating point with negative zero") { | ||
| val schema = StructType( | ||
| Seq( | ||
| StructField( | ||
| "float_struct", | ||
| StructType(Seq(StructField("c0", DataTypes.FloatType, true)))), | ||
| StructField( | ||
| "float_double", | ||
| StructType(Seq(StructField("c0", DataTypes.DoubleType, true)))))) | ||
| val df = FuzzDataGenerator.generateDataFrame( | ||
| new Random(42), | ||
| spark, | ||
| schema, | ||
| 1000, | ||
| DataGenOptions(generateNegativeZero = true)) | ||
| df.createOrReplaceTempView("tbl") | ||
|
|
||
| withSQLConf(CometConf.getExprAllowIncompatConfigKey("SortOrder") -> "false") { | ||
| checkSparkAnswerAndFallbackReason( | ||
| "select * from tbl order by 1, 2", | ||
| "unsupported range partitioning sort order") | ||
| } | ||
| } | ||
|
|
||
| test("compare true/false to negative zero") { | ||
| Seq(false, true).foreach { dictionary => | ||
| withSQLConf("parquet.enable.dictionary" -> dictionary.toString) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
The method takes a
DataTypeparameter, so it seems redundant to include that in the method name as well?