fix: LIKE 'prefix%' pruning fails on Utf8View and LargeUtf8 columns#22562
Open
lyne7-sc wants to merge 2 commits into
Open
fix: LIKE 'prefix%' pruning fails on Utf8View and LargeUtf8 columns#22562lyne7-sc wants to merge 2 commits into
lyne7-sc wants to merge 2 commits into
Conversation
alamb
approved these changes
May 27, 2026
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn prune_like_prefix() { |
Contributor
There was a problem hiding this comment.
I verified that this test fails like this without the code chnage
thread 'parquet::row_group_pruning::prune_like_prefix' (83571793) panicked at datafusion/core/tests/parquet/row_group_pruning.rs:138:9:
assertion `left == right` failed: mismatched predicate_evaluation error
left: Some(5)
right: Some(0)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
| /// Wrap a string in a `Literal` whose `ScalarValue` matches `target_type` | ||
| fn string_literal_as(value: String, target_type: &DataType) -> Arc<dyn PhysicalExpr> { | ||
| let utf8 = ScalarValue::Utf8(Some(value)); | ||
| let scalar = try_cast_literal_to_type(&utf8, target_type).unwrap_or(utf8); |
Contributor
There was a problem hiding this comment.
👍
It is sad that this potentially results in a new allocation -- maybe as a follow on PR we can avoid the allocation in try_cast_literal_to_type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
LIKE 'prefix%' predicates on
Utf8ViewandLargeUtf8columns producepredicate_evaluation_errors, causing row group and page index pruning to be skipped entirely.The cause is
build_like_matchalways synthesizes bound literals asScalarValue::Utf8, regardless of the actual column type. When the column isUtf8VieworLargeUtf8, the subsequent comparison between the Utf8-typed bound and the min/max statistics (which use the column's native type) fails with a type mismatch error.What changes are included in this PR?
build_like_matchto usestring_literal_aswith the column's data_type() instead of hardcodingScalarValue::Utf8for the lower/upper bound literals.Are these changes tested?
Yes.
Are there any user-facing changes?
No.