mbutrovich commented on code in PR #17195:
URL: https://github.com/apache/datafusion/pull/17195#discussion_r2282951345


##########
datafusion/functions/src/regex/regexpreplace.rs:
##########
@@ -94,14 +98,30 @@ impl Default for RegexpReplaceFunc {
 
 impl RegexpReplaceFunc {
     pub fn new() -> Self {
-        use DataType::*;
+        use TypeSignature::*;
+        use TypeSignatureClass::*;
         Self {
             signature: Signature::one_of(
                 vec![
-                    TypeSignature::Exact(vec![Utf8, Utf8, Utf8]),

Review Comment:
   If I do the signature as...
   ```
               signature: Signature::one_of(
                   vec![
                       Exact(vec![Utf8, Utf8, Utf8]),
                       Exact(vec![LargeUtf8, LargeUtf8, LargeUtf8]),
                       Exact(vec![Utf8View, Utf8View, Utf8View]),
                       Exact(vec![Utf8, Utf8, Utf8, Utf8]),
                       Exact(vec![LargeUtf8, LargeUtf8, LargeUtf8, LargeUtf8]),
                       Exact(vec![Utf8View, Utf8View, Utf8View, Utf8View]),
                   ],
                   Volatility::Immutable,
               ),
   ```
   ...that generates this test failure:
   ```
   External error: 1 errors in file 
/Users/matt/git/datafusion/datafusion/sqllogictest/test_files/string/string_view.slt
   
   1. query result mismatch:
   [SQL] EXPLAIN SELECT
     REGEXP_REPLACE(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$', '\1') 
AS k
   FROM test;
   [Diff] (-expected|+actual)
       logical_plan
   -   01)Projection: regexp_replace(test.column1_utf8view, 
Utf8("^https?://(?:www\.)?([^/]+)/.*$"), Utf8("\1")) AS k
   +   01)Projection: regexp_replace(CAST(test.column1_utf8view AS Utf8), 
Utf8("^https?://(?:www\.)?([^/]+)/.*$"), Utf8("\1")) AS k
       02)--TableScan: test projection=[column1_utf8view]
   at 
/Users/matt/git/datafusion/datafusion/sqllogictest/test_files/string/string_view.slt:801
   ```
   which implies that a `Utf8View` column would get cast to `Utf8` with other 
`Utf8` literals as args. That's not good.
   
   The signature with `String(3)` or `String(4)` seems like the best option if 
I can understand why binary coercion does not work with that.



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to