Skip to content

fix: enable FIRST/LAST partial merge - #5041

Merged
comphead merged 5 commits into
apache:mainfrom
peterxcli:codex/issue-4131-last-value-partial-merge
Sep 9, 2026
Merged

fix: enable FIRST/LAST partial merge#5041
comphead merged 5 commits into
apache:mainfrom
peterxcli:codex/issue-4131-last-value-partial-merge

Conversation

@peterxcli

@peterxcli peterxcli commented Jul 26, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #4131.

Rationale for this change

DataFusion LAST_VALUE partial-state merging filtered unset states but selected element 0 from the final state array instead of its last element. This could make Comet produce a different result from Spark, so Comet temporarily fell back for FIRST/LAST in PartialMerge mode.

Upstream main uses DataFusion 55.0.0 and Arrow/Parquet 59.2.0 through merged #5262. The dependency upgrade is no longer a blocker. The root fix, apache/datafusion#23905, is included in DataFusion 55.0.0.

What changes are included in this PR?

  • The current draft includes the public backport dependency pin; remove it when rebasing onto main's DataFusion 55.0.0.
  • Remove the temporary FIRST/LAST PartialMerge fallback.
  • Change the existing FIRST/LAST PartialMerge SQL cases from fallback assertions to Spark/Comet result comparisons.

How are these changes tested?

The following results are from the backport-based draft, not a DataFusion 55.0.0 validation run. Rerun them after the rebase and dependency-pin cleanup.

  • cargo build --locked
  • JAVA_HOME=/Users/lixucheng/.sdkman/candidates/java/17.0.14-zulu make core
  • JAVA_HOME=/Users/lixucheng/.sdkman/candidates/java/17.0.14-zulu DYLD_LIBRARY_PATH=/Users/lixucheng/.sdkman/candidates/java/17.0.14-zulu/lib/server ./mvnw test -Dtest=none -Dsuites="org.apache.comet.CometSqlFileTestSuite partial_merge" -Dscalastyle.skip=true

The focused SQL suite passed both Parquet dictionary configurations: 2 tests run, 2 succeeded.

@peterxcli
peterxcli marked this pull request as ready for review September 5, 2026 19:28
@peterxcli
peterxcli force-pushed the codex/issue-4131-last-value-partial-merge branch from ea2e9b7 to 11fdb9a Compare September 5, 2026 20:19
@andygrove andygrove added bug Something isn't working area:aggregation Hash aggregates, aggregate expressions labels Sep 6, 2026
@peterxcli

Copy link
Copy Markdown
Member Author

cc @comphead ptal, thanks!

@comphead comphead left a comment

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.

Thanks @peterxcli it looks good to me, btw can we try to move impacted tests from suites to sql files if that possible

@comphead

comphead commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Hm, this PR ran incomplete CI

@comphead
comphead self-requested a review September 8, 2026 23:09
@peterxcli

Copy link
Copy Markdown
Member Author

btw can we try to move impacted tests from suites to sql files if that possible

done, thanks for the suggestion!

@comphead comphead left a comment

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.

Thanks @peterxcli

@comphead
comphead merged commit 424c31a into apache:main Sep 9, 2026
74 checks passed
@peterxcli
peterxcli deleted the codex/issue-4131-last-value-partial-merge branch September 9, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:aggregation Hash aggregates, aggregate expressions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support FIRST/LAST with PartialMerge

3 participants