Skip to content

fix: enable FIRST/LAST partial merge - #5041

Open
peterxcli wants to merge 5 commits into
apache:mainfrom
peterxcli:codex/issue-4131-last-value-partial-merge
Open

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

Conversation

@peterxcli

@peterxclipeterxcli 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
peterxcliforce-pushed the codex/issue-4131-last-value-partial-merge branch from ea2e9b7 to 11fdb9aCompareSeptember 5, 2026 20:19
@andygroveandygrove added bug Something isn't working area:aggregation Hash aggregates, aggregate expressions labels Sep 6, 2026
@peterxcli

Copy link
Copy Markdown
MemberAuthor

cc @comphead ptal, thanks!

@compheadcomphead 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

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
MemberAuthor

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

done, thanks for the suggestion!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:aggregationHash aggregates, aggregate expressionsbugSomething isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support FIRST/LAST with PartialMerge

3 participants

@peterxcli@comphead@andygrove