mbutrovich commented on code in PR #17195: URL: https://github.com/apache/datafusion/pull/17195#discussion_r2282923454
########## datafusion/functions/src/regex/regexpreplace.rs: ########## @@ -590,44 +638,1674 @@ pub fn specialize_regexp_replace<T: OffsetSizeTrait>( .map(|arg| arg.to_array(inferred_length)) .collect::<Result<Vec<_>>>()?; - match args[0].data_type() { - DataType::Utf8View => { - let string_array = args[0].as_string_view(); - let pattern_array = args[1].as_string::<i32>(); - let replacement_array = args[2].as_string::<i32>(); - regexp_replace::<i32, _, _>( - string_array, - pattern_array, - replacement_array, - args.get(3), - ) - } - DataType::Utf8 => { - let string_array = args[0].as_string::<i32>(); - let pattern_array = args[1].as_string::<i32>(); - let replacement_array = args[2].as_string::<i32>(); - regexp_replace::<i32, _, _>( - string_array, - pattern_array, - replacement_array, - args.get(3), - ) - } - DataType::LargeUtf8 => { - let string_array = args[0].as_string::<i64>(); - let pattern_array = args[1].as_string::<i64>(); - let replacement_array = args[2].as_string::<i64>(); - regexp_replace::<i64, _, _>( - string_array, - pattern_array, - replacement_array, - args.get(3), - ) + if args.get(3).is_none() { Review Comment: For the final query in regexp_replace.slt... ``` query TTT select regexp_replace(col, NULL, 'c'), regexp_replace(col, 'a', NULL), regexp_replace(col, 'a', 'c', NULL) from (values ('a'), ('b')) as tbl(col); ``` ...DataFusion's planner calls the `return_type` method with this schema: ``` [Utf8, Utf8View, Utf8] [Utf8, Utf8, Utf8View] [Utf8, Utf8, Utf8, Utf8View] ``` It seems like the literal NULL is a `Utf8View`, but the other columns are `Utf8`. Maybe if I tweak the signature to have fewer options the planner will introduce the necessary casts. I'm happy to reduce the supported types to cut down on generated code, but want to make sure we cover reasonable combinations. -- 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