Skip to content

fix: enable FIRST/LAST partial merge - #5041

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

fix: enable FIRST/LAST partial merge#5041
peterxcli wants to merge 3 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!

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

2 participants