u70b3 opened a new pull request, #23735:
URL: https://github.com/apache/datafusion/pull/23735

   ## Which issue does this PR close?
   
   - Closes #23732
   
   ## Rationale for this change
   
   Follow-up to #23704, which made the `TypeCoercion` analyzer coerce `SIMILAR 
TO` operands to a common string type. The SQL planner still rejects `LargeUtf8` 
and `Utf8View` **patterns** before the analyzer ever runs:
   
   ```sql
   SELECT s FROM test, patterns WHERE s SIMILAR TO arrow_cast(pat, 'Utf8View');
   -- error: Invalid pattern in SIMILAR TO expression
   ```
   
   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 in 
`sql_similarto_to_expr` now accepts `Utf8` / `LargeUtf8` / `Utf8View` / `Null` 
instead of only `Utf8` / `Null`.
   - `datafusion/sqllogictest/test_files/type_coercion.slt`: regression tests 
with non-literal `Utf8View` and `LargeUtf8` patterns (plus a `NOT SIMILAR TO` 
case), next to the existing #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 TO` queries with non-literal `LargeUtf8` / `Utf8View` patterns 
that previously failed during SQL planning with `Invalid pattern in SIMILAR TO 
expression` now plan and execute successfully. No breaking API changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to