Skip to content

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

Merged
huaxingao merged 10 commits intoapache:mainfrom
huaxingao:range_offset
Sep 23, 2024
Merged

fix: window function range offset should be long instead of int#733
huaxingao merged 10 commits intoapache:mainfrom
huaxingao:range_offset

Conversation

@huaxingao
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

What changes are included in this PR?

How are these changes tested?

df.select(
$"key",
count("key").over(
sum("key").over(
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@huaxingao huaxingao force-pushed the range_offset branch 3 times, most recently from 2e03816 to 1f8a29e Compare August 22, 2024 17:00
@codecov-commenter
Copy link
Copy Markdown

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
Copy Markdown
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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't use Groups, but if we don't specify this case, UpperFrameBoundStruct::UnboundedFollowing(_) => match units fails with pattern datafusion_expr::WindowFrameUnits::Groups not covered.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add it as separate pattern branch and return error?

Comment on lines +3327 to +3330
if (partitionColumnNames.toSet != orderColumnNames.toSet) {
withInfo(op, "Partitioning and sorting specifications do not match")
return false
}
Copy link
Copy Markdown
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks!

@huaxingao huaxingao merged commit 459b2b0 into apache:main Sep 23, 2024
@huaxingao huaxingao deleted the range_offset branch September 23, 2024 21:12
@huaxingao
Copy link
Copy Markdown
Contributor Author

Merged. Thanks @viirya @kazuyukitanimura

coderfender pushed a commit to coderfender/datafusion-comet that referenced this pull request Dec 13, 2025
## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->

N/A

## Rationale for this change

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->

Apply OSS 0.3.0 changes.

## What changes are included in this PR?

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

```
84cccf7 docs: Add notes for IntelliJ code size limits for code inspections. (apache#985)
dcc4a8a fix: The spilled_bytes metric of CometSortExec should be size instead of time (apache#984)
f64553b chore: fix compatibility guide (apache#978)
0ee7df8 chore: Enable additional CreateArray tests (apache#928)
a690e9d perf: Remove one redundant CopyExec for SMJ (apache#962)
a8156b5 chore: update rem expression guide (apache#976)
317a534 fix: Use the number of rows from underlying arrays instead of logical row count from RecordBatch (apache#972)
22561c4 doc: add documentation interlinks (apache#975)
b4de8e0 chore: Update benchmarks results based on 0.3.0-rc1 (apache#969)
94093f3 chore: fix publish-to-maven script (apache#966)
f31f6cc Generate changelog for 0.3.0 release (apache#964)
5663fc2 fix: div and rem by negative zero (apache#960)
50517f6 perf: Optimize decimal precision check in decimal aggregates (sum and avg) (apache#952)
5b3f7bc fix: CometScanExec on Spark 3.5.2 (apache#915)
8410c71 chore: clarify tarball installation (apache#959)
459b2b0 fix: window function range offset should be long instead of int (apache#733)
```


## How are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
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