kartik00052 opened a new pull request, #27660:
URL: https://github.com/apache/datafusion/pull/27660
## Which issue does this PR close?
- Closes #27628.
## Rationale for this change
A predicate such as `WHERE s NOT IN ('val_1', NULL) AND s ILIKE 'val_%'`
simplifies to `NULL AND s ILIKE 'val_%'`. `EliminateFilter` did not recognize
`Expr::Like` as safe to discard, so the plan kept a `FilterExec` with the
`NULL` conjunct and the Parquet scan decoded all 5 row groups (5,000 rows)
before filtering every row out. The query cannot match any rows and should fold
to an empty plan during optimization.
## What changes are included in this PR?
- Add `Expr::Like` (which also covers `ILIKE`) to `is_safe_to_discard` when
the escape character is the default backslash (`None` or `Some('\\')`),
recursing into `expr` and `pattern`.
- Exclude non-default escape characters: the physical planner rejects them
with an error, and folding such a predicate would suppress that error.
- Add optimizer unit tests for `LIKE`/`ILIKE` with a `NULL` conjunct in both
`AND` orders, fallible children, and non-default escapes.
- Add sqllogictest coverage in `in_list.slt`.
- Leave `PruningPredicate` changes as a follow-up; this PR fixes the
optimizer layer only.
- No public API changes.
## What is the testing strategy for this PR?
- Optimizer unit tests verify the plan folds to `EmptyRelation` for
default-escape `LIKE`/`ILIKE` with a `NULL` conjunct, and that fallible
children or non-default escapes are not discarded.
- `cargo fmt --all -- --check` passed.
- `cargo clippy -p datafusion-optimizer -p datafusion-sqllogictest
--all-targets -- -D warnings` passed.
- `cargo test -p datafusion-optimizer` passed (985 tests).
- `cargo test -p datafusion-pruning` passed (117 tests).
- `cargo test --doc -p datafusion-optimizer` passed.
- `cargo test --test sqllogictests` passed with initialized submodules
(309/309 files).
- `ci/scripts/typos_check.sh` and `ci/scripts/license_header.sh` passed.
- `ci/scripts/rust_docs.sh` passed (`RUSTDOCFLAGS="-D warnings" cargo doc
--document-private-items --no-deps --workspace`).
## Are there any user-facing changes?
No.
--
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]