-
Notifications
You must be signed in to change notification settings - Fork 260
feat: Support ANSI mode avg expr (int inputs) #2817
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
Open
coderfender
wants to merge
18
commits into
apache:main
Choose a base branch
from
coderfender:add_support_ansi_mode_avg_expr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+99
−30
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c60d2db
support_ansi_avg_wip
coderfender 07c6acd
support_ansi_avg_wip
coderfender d1b474c
support_ansi_avg
coderfender 33b0b2f
support_ansi_avg
coderfender 444ce0e
support_ansi_avg
coderfender ceab097
Merge branch 'main' into add_support_ansi_mode_avg_expr
coderfender 2845d62
rebase_main
coderfender df45851
address_review_comments
coderfender 512cc6b
address_review_comments
coderfender 25bae54
address_review_comments
coderfender 57e3de8
address_review_comments
coderfender 9791368
address_review_comments
coderfender ef4ecdc
address_review_comments
coderfender afe5f24
address_review_comments
coderfender 2aab2f4
Merge branch 'main' into add_support_ansi_mode_avg_expr
coderfender a60574f
address_review_comments
coderfender 6781b7c
address_review_comments_fix_clippy
coderfender b444cba
address_review_comments_fix_clippy
coderfender 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
Some comments aren't visible on the classic Files Changed page.
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
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 |
|---|---|---|
|
|
@@ -1471,6 +1471,89 @@ class CometAggregateSuite extends CometTestBase with AdaptiveSparkPlanHelper { | |
| } | ||
| } | ||
|
|
||
| test("AVG and try_avg - basic functionality") { | ||
| withParquetTable( | ||
| Seq( | ||
| (10L, 1), | ||
coderfender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (20L, 1), | ||
| (null.asInstanceOf[Long], 1), | ||
| (100L, 2), | ||
| (200L, 2), | ||
coderfender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (null.asInstanceOf[Long], 3)), | ||
| "tbl") { | ||
|
|
||
| Seq(true, false).foreach({ ansiMode => | ||
| // without GROUP BY | ||
| withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiMode.toString) { | ||
| val res = sql("SELECT avg(_1) FROM tbl") | ||
| checkSparkAnswerAndOperator(res) | ||
|
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. The last nit: can we remove |
||
| } | ||
|
|
||
| // with GROUP BY | ||
| withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiMode.toString) { | ||
| val res = sql("SELECT _2, avg(_1) FROM tbl GROUP BY _2") | ||
| checkSparkAnswerAndOperator(res) | ||
| } | ||
| }) | ||
|
|
||
| // try_avg without GROUP BY | ||
| val resTry = sql("SELECT try_avg(_1) FROM tbl") | ||
| checkSparkAnswerAndOperator(resTry) | ||
|
|
||
| // try_avg with GROUP BY | ||
| val resTryGroup = sql("SELECT _2, try_avg(_1) FROM tbl GROUP BY _2") | ||
| checkSparkAnswerAndOperator(resTryGroup) | ||
|
|
||
| } | ||
| } | ||
|
|
||
| test("AVG and try_avg - special numbers") { | ||
|
|
||
| val negativeNumbers: Seq[(Long, Int)] = Seq( | ||
| (-1L, 1), | ||
| (-123L, 1), | ||
| (-456L, 1), | ||
| (Long.MinValue, 1), | ||
| (Long.MinValue, 1), | ||
| (Long.MinValue, 2), | ||
| (Long.MinValue, 2), | ||
| (null.asInstanceOf[Long], 3)) | ||
|
|
||
| val zeroSeq: Seq[(Long, Int)] = | ||
| Seq((0L, 1), (-0L, 1), (+0L, 2), (+0L, 2), (null.asInstanceOf[Long], 3)) | ||
|
|
||
| val highValNumbers: Seq[(Long, Int)] = Seq( | ||
| (Long.MaxValue, 1), | ||
| (Long.MaxValue, 1), | ||
| (Long.MaxValue, 2), | ||
| (Long.MaxValue, 2), | ||
| (null.asInstanceOf[Long], 3)) | ||
|
|
||
| val inputs = Seq(negativeNumbers, highValNumbers, zeroSeq) | ||
| inputs.foreach(inputSeq => { | ||
| withParquetTable(inputSeq, "tbl") { | ||
| Seq(true, false).foreach({ ansiMode => | ||
| // without GROUP BY | ||
| withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiMode.toString) { | ||
| checkSparkAnswerAndOperator("SELECT avg(_1) FROM tbl") | ||
| } | ||
|
|
||
| // with GROUP BY | ||
| withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiMode.toString) { | ||
| checkSparkAnswerAndOperator("SELECT _2, avg(_1) FROM tbl GROUP BY _2") | ||
| } | ||
| }) | ||
|
|
||
| // try_avg without GROUP BY | ||
| checkSparkAnswerAndOperator("SELECT try_avg(_1) FROM tbl") | ||
|
|
||
| // try_avg with GROUP BY | ||
| checkSparkAnswerAndOperator("SELECT _2, try_avg(_1) FROM tbl GROUP BY _2") | ||
|
|
||
| } | ||
| }) | ||
| } | ||
|
|
||
| test("ANSI support for sum - null test") { | ||
| Seq(true, false).foreach { ansiEnabled => | ||
| withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiEnabled.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.
Uh oh!
There was an error while loading. Please reload this page.