Copilot commented on code in PR #23722:
URL: https://github.com/apache/datafusion/pull/23722#discussion_r3618579463
##########
datafusion/sqllogictest/test_files/regexp/regexp_match.slt:
##########
@@ -199,3 +199,22 @@ query B
select null !~* 'abc';
----
NULL
+
+
+# Test for Issue 23709: regex_match_dyn with Dictionary encoded patterns
Review Comment:
The test comment says "Dictionary encoded patterns", but the reproducer (and
the query below) dictionary-encodes the **value** side (`dict_regex_t.s`), not
the pattern. This is misleading when someone later looks for dictionary pattern
coverage.
##########
datafusion/physical-expr/src/expressions/binary/kernels.rs:
##########
@@ -200,6 +196,15 @@ pub(crate) fn regex_match_dyn(
DataType::LargeUtf8 => {
regexp_is_match_flag!(left, right, LargeStringArray, not_match,
flag)
}
+ DataType::Dictionary(_, _) => {
+ let dict = left.as_any_dictionary();
+ let unpacked_left = arrow::compute::kernels::take::take(
+ dict.values().as_ref(),
+ dict.keys(),
+ None,
+ )?;
+ regex_match_dyn(&unpacked_left, right, not_match, flag)
+ }
Review Comment:
`regex_match_dyn` now unwraps Dictionary-encoded `left` via `take` and then
recursively dispatches using the *unpacked* left type. If `right` is still
Dictionary-encoded (or otherwise a different string representation such as
`Utf8View` vs `Utf8`), the downstream `regexp_is_match_flag!` macro will
attempt to downcast `right` to the same array type as `left` and will panic on
the `expect("failed to downcast array")` path. This is a behavior regression
from returning an internal error for Dictionary types, and can surface if both
operands are dictionary-encoded (or have been coerced to different string view
types).
--
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]