Skip to content

chore: rebase Greptime thin fork onto DataFusion 54.1 - #21

Closed
discord9 wants to merge 14 commits into
greptimedb-54.1.0from
thin-fork/2026-07-22-datafusion-54.1
Closed

chore: rebase Greptime thin fork onto DataFusion 54.1#21
discord9 wants to merge 14 commits into
greptimedb-54.1.0from
thin-fork/2026-07-22-datafusion-54.1

Conversation

@discord9

@discord9 discord9 commented Jul 23, 2026

Copy link
Copy Markdown

Which issue does this PR close?

N/A — issues are disabled on this maintenance fork. This replacement is tracked by GreptimeDB PR #8555 and supersedes GreptimeTeam/datafusion#20.

Rationale for this change

GreptimeDB is upgrading from its DataFusion 53.1 maintenance branch to DataFusion 54.1. The first thin-fork proposal (#20) was built on official 54.0.0. Since then, official 54.1.0 shipped 20 backports, including an adapted version of the volatile file-scan projection fix that #20 carried locally.

This replacement starts from the exact official 54.1.0 commit 0d1f2ebe2cc97c91b736bc0a160b5b73cf40437a, drops the now-upstream volatile projection patch, and carries only the correctness fixes still required by GreptimeDB. It keeps the organization branch reviewable instead of making the official 54.1 update appear as part of a PR based on greptimedb-54.0.0.

What changes are included in this PR?

Base:

GreptimeTeam/datafusion:greptimedb-54.1.0
0d1f2ebe2cc97c91b736bc0a160b5b73cf40437a

Retained fixes, replayed with provenance from the validated 54.0 stack:

Source Correctness behavior retained Source commit 54.1 commit
GreptimeTeam #5 Preserve mixed aggregate-filter predicate order 7303323513 a60023a3a
GreptimeTeam #16 / Apache apache#23357 Account for grouped AVG/MEDIAN accumulator memory 467e7ec99f e5cfcc3a8
GreptimeTeam #14 / Apache apache#23271 Count ragged nested-array cardinality recursively c349e4b388 062d818d9
GreptimeTeam #15 / Apache apache#23306 Bound array_resize by Arrow's maximum array size 9297b40fd4 e4231af92
GreptimeTeam #4 / Apache apache#22759 Preserve finer timestamp precision during coercion 557ddad236 a286efa5d
GreptimeTeam #13 Make fetch-aware statistics safe and apply them to SortPreservingMergeExec e2be63976c 4b31e11d0
GreptimeTeam #12 Preserve global LIMIT/OFFSET semantics across partitions d385af852d 33f4161e7
DF54 follow-up Keep safe TRY_CAST scalar/array overflow behavior nullable fb7b26d04c 218a14c53
GreptimeTeam #11 Replace unsafe cast unwrapping with exact/range cast preimages 027358559b 887df12d5
DF54 follow-up Return SQL NULL for exact median(NULL) and fall back from grouped accumulation 0f6dcb128 d450ac6b5
DF54 follow-up Preserve duplicate Substrait root names with deterministic internal qualifiers cee35d94c 33e6bb173
Apache apache#23677 Preserve global ORDER BY requirements below ScalarSubqueryExec roots 9eae6da6f 43a6b5750
GreptimeTeam #22 Preserve NULLs when evaluating regex predicates on dictionary values aa6f9fa05 b1f616b1d
GreptimeTeam #23 Rewrite ordered coarse-to-fine timestamp-widening predicates to source-domain bounds (ceil/floor, aligned and non-aligned) f2a0b22e4 d75a5582a

Explicitly not replayed:

The resulting candidate head is d75a5582a7112e11bf2f36449f47fd60ac820a05, exactly 14 commits above the official 54.1 base.

Overflow policy disclosure (GreptimeTeam #23)

The ordered timestamp-widening rewrite introduced in d75a5582a is applied with the same accepted fork policy as the merged DF53 PR #23: the ordered source bound is exactly equivalent only for source values whose widening is representable. Outside that domain a regular CAST can error and TRY_CAST can return NULL, while the rewrite still emits the source-domain predicate. No full-domain equivalence is claimed; the commit message and datafusion/expr-common/src/casts.rs document this trade-off.

Are these changes tested?

Each retained semantic change has focused regression coverage from the original test-first port. The 54.1 replacement additionally requires:

  • ancestry and exact commit count from 0d1f2ebe2;
  • range-diff against the validated 54.0 stack;
  • no thin-fork diff in the official volatile projection implementation, its Cargo files, or its SQL logic test;
  • workspace format and diff checks;
  • focused tests for the changed optimizer, function, physical-expression, physical-plan, and Substrait crates;
  • cargo clippy --all-targets --all-features -- -D warnings;
  • DataFusion SQL logic tests, core/CLI tests, and the complete Substrait suite.

Actual completed evidence before submission:

discord9 added 11 commits July 23, 2026 15:49
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit 7303323)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit 467e7ec)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit c349e4b)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit 9297b40)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit 557ddad)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit e2be639)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit d385af8)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit fb7b26d)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit 0273585)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit 0f6dcb1)
Signed-off-by: discord9 <discord9@163.com>
(cherry picked from commit cee35d9)
Signed-off-by: discord9 <discord9@163.com>
Ports GreptimeTeam/datafusion PR #22
(commit aa6f9fa) onto the 54.1 thin
fork.

regex_match_dyn_scalar re-materialized the evaluated dictionary values
with take_iter, which discarded the validity of the evaluated values
array. Use arrow::compute::take so NULLs from both the dictionary keys
and the evaluated values are preserved, matching plain utf8 regex
evaluation.

Signed-off-by: discord9 <discord9@163.com>
Ports GreptimeTeam/datafusion PR #23
(source commit f2a0b22) onto the 54.1
thin fork.

Ordered comparisons (>=, <, >, <=) over a coarse-to-fine timestamp
widening cast now rewrite to a source-domain bound: >= and < use ceil,
> and <= use floor, computed with i128 div_euclid/rem_euclid for both
aligned and non-aligned target literals (aligned values collapse to the
common bound). The rewrite is limited to coarse->fine timestamp units
with identical timezone metadata and a target-typed non-NULL literal;
it does not extend to equality/IN, timezone changes, or other cast
families.

Overflow policy: the ordered source bound is equivalent only for source
values whose widening is representable. In line with the accepted DF53
fork PR #23 policy, this fork also applies the rewrite outside that
domain, where regular CAST can error and TRY_CAST can return NULL. No
full-domain equivalence is claimed.

Preserved protections: equality/IN, typed NULL, timezone mismatch,
dictionary, and non-default physical cast options / target field
metadata all retain the cast.

Signed-off-by: discord9 <discord9@163.com>
@discord9

discord9 commented Aug 4, 2026

Copy link
Copy Markdown
Author

Closing per decision: GreptimeDB will consume the org thin-fork/2026-07-22-datafusion-54.1 branch directly, pinned at its current head d75a5582a7112e11bf2f36449f47fd60ac820a05 (already the rev in GreptimeDB's Cargo.toml). Future thin-fork advances will update that pinned rev directly; no PR review shell is needed.

@discord9 discord9 closed this Aug 4, 2026
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.

1 participant