-
Notifications
You must be signed in to change notification settings - Fork 182
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
fix: Mark cast from float/double to decimal as incompatible #1372
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d1e7dba
add failing test
andygrove d7979e1
Mark cast from float/double to decimal as incompat
andygrove 66d25c3
update docs
andygrove 2e61c79
update cast tests
andygrove 0c5fdcd
link to issue
andygrove 1fc6abe
fix regressions
andygrove 1f8a351
use unique table name in test
andygrove 206efe0
use withTable
andygrove 880328b
address feedback
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 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 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 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 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 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 |
---|---|---|
|
@@ -32,13 +32,35 @@ import org.apache.spark.sql.internal.SQLConf | |
|
||
import org.apache.comet.CometConf | ||
import org.apache.comet.CometSparkSessionExtensions.isSpark34Plus | ||
import org.apache.comet.testing.{DataGenOptions, ParquetGenerator} | ||
|
||
/** | ||
* Test suite dedicated to Comet native aggregate operator | ||
*/ | ||
class CometAggregateSuite extends CometTestBase with AdaptiveSparkPlanHelper { | ||
import testImplicits._ | ||
|
||
test("avg decimal") { | ||
withTempDir { dir => | ||
val path = new Path(dir.toURI.toString, "test.parquet") | ||
val filename = path.toString | ||
val random = new Random(42) | ||
withSQLConf(CometConf.COMET_ENABLED.key -> "false") { | ||
ParquetGenerator.makeParquetFile(random, spark, filename, 10000, DataGenOptions()) | ||
} | ||
val tableName = "avg_decimal" | ||
withTable(tableName) { | ||
val table = spark.read.parquet(filename).coalesce(1) | ||
table.createOrReplaceTempView(tableName) | ||
// we fall back to Spark for avg on decimal due to the following issue | ||
// https://github.com/apache/datafusion-comet/issues/1371 | ||
// once this is fixed, we should change this test to | ||
// checkSparkAnswerAndNumOfAggregates | ||
checkSparkAnswer(s"SELECT c1, avg(c7) FROM $tableName GROUP BY c1 ORDER BY c1") | ||
} | ||
} | ||
} | ||
|
||
test("stddev_pop should return NaN for some cases") { | ||
withSQLConf( | ||
CometConf.COMET_EXEC_SHUFFLE_ENABLED.key -> "true", | ||
|
@@ -867,10 +889,11 @@ class CometAggregateSuite extends CometTestBase with AdaptiveSparkPlanHelper { | |
|
||
withSQLConf( | ||
CometConf.COMET_EXEC_SHUFFLE_ENABLED.key -> "true", | ||
CometConf.COMET_CAST_ALLOW_INCOMPATIBLE.key -> "true", | ||
CometConf.COMET_SHUFFLE_MODE.key -> "native") { | ||
Seq(true, false).foreach { dictionaryEnabled => | ||
withSQLConf("parquet.enable.dictionary" -> dictionaryEnabled.toString) { | ||
val table = "t1" | ||
val table = s"final_decimal_avg_$dictionaryEnabled" | ||
Comment on lines
-873
to
+896
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. These changes ended up not being entirely necessary, but the test did have a mix of hard-coded |
||
withTable(table) { | ||
sql(s"create table $table(a decimal(38, 37), b INT) using parquet") | ||
sql(s"insert into $table values(-0.0000000000000000000000000000000000002, 1)") | ||
|
@@ -884,13 +907,13 @@ class CometAggregateSuite extends CometTestBase with AdaptiveSparkPlanHelper { | |
sql(s"insert into $table values(0.13344406545919155429936259114971302408, 5)") | ||
sql(s"insert into $table values(0.13344406545919155429936259114971302408, 5)") | ||
|
||
checkSparkAnswerAndNumOfAggregates("SELECT b , AVG(a) FROM t1 GROUP BY b", 2) | ||
checkSparkAnswerAndNumOfAggregates("SELECT AVG(a) FROM t1", 2) | ||
checkSparkAnswerAndNumOfAggregates(s"SELECT b , AVG(a) FROM $table GROUP BY b", 2) | ||
checkSparkAnswerAndNumOfAggregates(s"SELECT AVG(a) FROM $table", 2) | ||
checkSparkAnswerAndNumOfAggregates( | ||
"SELECT b, MIN(a), MAX(a), COUNT(a), SUM(a), AVG(a) FROM t1 GROUP BY b", | ||
s"SELECT b, MIN(a), MAX(a), COUNT(a), SUM(a), AVG(a) FROM $table GROUP BY b", | ||
2) | ||
checkSparkAnswerAndNumOfAggregates( | ||
"SELECT MIN(a), MAX(a), COUNT(a), SUM(a), AVG(a) FROM t1", | ||
s"SELECT MIN(a), MAX(a), COUNT(a), SUM(a), AVG(a) FROM $table", | ||
2) | ||
} | ||
} | ||
|
@@ -915,7 +938,7 @@ class CometAggregateSuite extends CometTestBase with AdaptiveSparkPlanHelper { | |
withSQLConf( | ||
CometConf.COMET_EXEC_SHUFFLE_ENABLED.key -> "true", | ||
CometConf.COMET_SHUFFLE_MODE.key -> "native") { | ||
val table = "t1" | ||
val table = "avg_null_handling" | ||
withTable(table) { | ||
sql(s"create table $table(a double, b double) using parquet") | ||
sql(s"insert into $table values(1, 1.0)") | ||
|
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.
Would you mind adding
// https://github.com/apache/datafusion-comet/issues/1371
and mention to usecheckSparkAnswerAndNumOfAggregates
once resolved?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.
Added