fix: accept LargeUtf8 and Utf8View patterns in SIMILAR TO planning#23735
Open
u70b3 wants to merge 2 commits into
Open
fix: accept LargeUtf8 and Utf8View patterns in SIMILAR TO planning#23735u70b3 wants to merge 2 commits into
u70b3 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23735 +/- ##
==========================================
- Coverage 80.71% 80.71% -0.01%
==========================================
Files 1089 1089
Lines 368750 368751 +1
Branches 368750 368751 +1
==========================================
- Hits 297631 297627 -4
- Misses 53375 53376 +1
- Partials 17744 17748 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
u70b3
force-pushed
the
similar-to-pattern-types
branch
from
July 21, 2026 06:09
f9061a3 to
69f531e
Compare
adriangb
reviewed
Jul 21, 2026
| SELECT t.s NOT SIMILAR TO arrow_cast(p.pat, 'Utf8View') FROM t CROSS JOIN p; | ||
| ---- | ||
| false | ||
|
|
Contributor
There was a problem hiding this comment.
Can we add tests for teh null case?
Contributor
Author
There was a problem hiding this comment.
Done in add3f8d — added a literal NULL pattern in the table context and a non-scalar Null-typed pattern column (CREATE TABLE pn AS SELECT NULL AS pat), both evaluate to NULL.
Closes apache#23732. Follow-up to apache#23704: now that the TypeCoercion analyzer coerces SIMILAR TO operands to a common string type, the SQL planner no longer needs to reject LargeUtf8/Utf8View patterns (consistent with LIKE, which has no such check).
u70b3
force-pushed
the
similar-to-pattern-types
branch
from
July 21, 2026 11:09
add3f8d to
7738741
Compare
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
Follow-up to #23704, which made the
TypeCoercionanalyzer coerceSIMILAR TOoperands to a common string type. The SQL planner still rejectsLargeUtf8andUtf8Viewpatterns before the analyzer ever runs:Now that the analyzer coerces both operands, this planner restriction is unnecessary (and inconsistent with
LIKE, whose planner path has no such check).What changes are included in this PR?
datafusion/sql/src/expr/mod.rs: the pattern-type check insql_similarto_to_exprnow acceptsUtf8/LargeUtf8/Utf8View/Nullinstead of onlyUtf8/Null.datafusion/sqllogictest/test_files/type_coercion.slt: regression tests with non-literalUtf8ViewandLargeUtf8patterns (plus aNOT SIMILAR TOcase), next to the existing SIMILAR TO panics ('failed to downcast array') when operand types differ (e.g. NULL pattern, Utf8View vs Utf8) #22886 regression tests.The planner relaxation and tests were originally part of #22887; this PR lands the remaining piece of it.
Are these changes tested?
Yes — new sqllogictest cases in
type_coercion.slt. The existing planner rejection of non-string patterns (SELECT 'a' SIMILAR TO 1) still errors as before.Are there any user-facing changes?
Yes:
SIMILAR TOqueries with non-literalLargeUtf8/Utf8Viewpatterns that previously failed during SQL planning withInvalid pattern in SIMILAR TO expressionnow plan and execute successfully. No breaking API changes.