Repository navigation
Commit 8464286
fix: accept LargeUtf8 and Utf8View patterns in SIMILAR TO planning (apache#23735)
## Which issue does this PR close?
- Closes apache#23732
## Rationale for this change
Follow-up to apache#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 apache#22886 regression tests.
The planner relaxation and tests were originally part of apache#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.1 parent c8c1521 commit 8464286
2 files changed
Lines changed: 43 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1008 | 1008 | | |
1009 | 1009 | | |
1010 | 1010 | | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | 1011 | | |
1016 | 1012 | | |
1017 | 1013 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
| |||
349 | 351 | | |
350 | 352 | | |
351 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
352 | 392 | | |
353 | 393 | | |
354 | 394 | | |
| |||
359 | 399 | | |
360 | 400 | | |
361 | 401 | | |
362 | | - | |
363 | | - | |
| 402 | + | |
| 403 | + | |
364 | 404 | | |
0 commit comments