Repro
SELECT 'ababac' LIKE 'abab%%%%%';
Actual
The query fails with an internal panic:
Code: 1104
assertion failed: segments_len > 1
Panic site:
src/query/expression/src/filter/like.rs:144
Expected
Databend should either:
- normalize redundant
% and return the correct boolean result, or
- return a regular SQL error
It must not panic.
Why this looks like the root cause
TypeChecker::resolve_like() can route constant LIKE expressions into constant folding, which eventually evaluates LikePattern::simple_pattern(). That function contains:
debug_assert!(segments_len > 1);
at:
src/query/expression/src/filter/like.rs:144
Repeated % can collapse the pattern into too few segments, violating that assumption and triggering the panic.
Impact
panic.log shows this happened 7 times in one migration batch.
- It blocks automatic conversion of DuckDB
LIKE coverage and turns a deterministic SQL case into an internal error.
Suggested fix direction
- Normalize repeated
% before building LikePattern, or
- make
simple_pattern() handle segments_len <= 1 safely instead of asserting
Repro
Actual
The query fails with an internal panic:
Panic site:
src/query/expression/src/filter/like.rs:144Expected
Databend should either:
%and return the correct boolean result, orIt must not panic.
Why this looks like the root cause
TypeChecker::resolve_like()can route constantLIKEexpressions into constant folding, which eventually evaluatesLikePattern::simple_pattern(). That function contains:at:
src/query/expression/src/filter/like.rs:144Repeated
%can collapse the pattern into too few segments, violating that assumption and triggering the panic.Impact
panic.logshows this happened 7 times in one migration batch.LIKEcoverage and turns a deterministic SQL case into an internal error.Suggested fix direction
%before buildingLikePattern, orsimple_pattern()handlesegments_len <= 1safely instead of asserting