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

fix: window function range offset should be long instead of int #733

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

huaxingao
Copy link
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

What changes are included in this PR?

How are these changes tested?

val df =
Seq((1L, "1"), (1L, "1"), (2147483650L, "1"), (3L, "2"), (2L, "1"), (2147483650L, "2"))
.toDF("key", "value")

checkAnswer(
df.select(
$"key",
count("key").over(
sum("key").over(
Copy link
Contributor

Choose a reason for hiding this comment

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

So this test fails before this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We currently don't support count so change to sum. Previously, even if the aggregate function is not supported, it still goes to the window frame code. In this PR, I return None directly if aggregate function is not supported.

Comment on lines 291 to 292
throw new IllegalArgumentException(
"Unsupported data type for window function row/range offset")
Copy link
Member

Choose a reason for hiding this comment

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

You will fail the query directly instead of falling back to Spark.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to return None to fall back to Spark

@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 52.94118% with 16 lines in your changes missing coverage. Please review.

Project coverage is 34.16%. Comparing base (9d8730d) to head (2777d18).
Report is 7 commits behind head on main.

Files Patch % Lines
.../scala/org/apache/comet/serde/QueryPlanSerde.scala 52.94% 6 Missing and 10 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               main     #733       +/-   ##
=============================================
- Coverage     55.16%   34.16%   -21.00%     
- Complexity      857      881       +24     
=============================================
  Files           109      112        +3     
  Lines         10542    42949    +32407     
  Branches       2010     9491     +7481     
=============================================
+ Hits           5815    14673     +8858     
- Misses         3714    25274    +21560     
- Partials       1013     3002     +1989     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

WindowFrameUnits::Rows => {
WindowFrameBound::Preceding(ScalarValue::UInt64(None))
}
WindowFrameUnits::Range | WindowFrameUnits::Groups => {
Copy link
Member

Choose a reason for hiding this comment

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

Do we use Groups?

Comment on lines +3327 to +3330
if (partitionColumnNames.toSet != orderColumnNames.toSet) {
withInfo(op, "Partitioning and sorting specifications do not match")
return false
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe check the partition column and order column one by one instead of a set? I'm not sure if (PARTITION BY k, v ORDER BY v, k) work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants