Repository navigation
fix: evaluate shared volatile struct fields once on branch-55 - #196
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## branch-55 #196 +/- ##
===========================================
Coverage 81.22% 81.23%
===========================================
Files 1111 1111
Lines 389078 389273 +195
Branches 389078 389273 +195
===========================================
+ Hits 316046 316226 +180
+ Misses 54358 54356 -2
- Partials 18674 18691 +17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ssions (apache#24720) Keep an extraction above a projection when inlining the source expression would evaluate a volatile value twice. Cover projected fields and filter predicates that read the same struct. (cherry picked from commit 27e81e9)
Count references to the same output field before merging logical or physical projections. Keep independent volatile calls separate and let file metadata expressions reach their scans across a limit or union. Exercise the affected paths with a counter UDF, struct comparisons and Parquet row indices.
The pinned MinIO image returns HTTP 404 on branch-55. Start RustFS and upload the existing fixtures so CI can exercise the same CLI queries.
65ca6fe to
dc7d083
Compare
|
@gabotechs, the backport is ready for review on I reproduced both wrong results on the current base. A field disagreed with its struct, and some returned rows failed their filter. Both queries returned the expected result after the rebase. In the top-two query, both versions returned 20 and 19, while the counted UDF processed 40 rows on the base and two on this branch. The extended workspace suite, RustFS-backed CLI tests, and lint passed locally. Criterion reported no regression in the projection benchmarks against |
Which issue does this PR close?
Backports the fix for inconsistent reads of volatile struct fields to
branch-55. Upstream issue, upstream fixRationale for this change
On
branch-55, selecting both a struct containingrandom()and a field from that struct can produce two different values for the same field. A filter can also return rows that fail its own predicate.Repeated evaluation can add cost for a model-backed UDF. In a 20-row query that sorts its input, keeps two rows and reads two struct fields, the UDF processed 40 rows on the base and two with the fix. Both returned 20 and 19. A monthly savings estimate would require production query volume and cost per row.
What changes are included in this PR?
Projection merging keeps one evaluation for each shared volatile value, including after physical optimization. Separately written calls remain independent. Keeping the defining projection can limit column pruning in affected plans. File metadata expressions can still reach their Parquet scans when a sibling field reads a volatile value.
A separate test-only commit switches the CLI S3 fixture to RustFS. The pinned MinIO image returns HTTP 404 on the current base. Failing base job
Are these changes tested?
SQL regressions cover struct and filter agreement, joins, nested projections, and Parquet row indices across a limit and a union. A counter UDF checks that physical optimization preserves a shared result.
Are there any user-facing changes?
A projected field and a filter now read the same value as the returned struct.
This backport was prepared with AI assistance. If maintaining it on
branch-55is not worth the benefit, please close the PR with a brief rationale.