Jefffrey commented on code in PR #22244:
URL: https://github.com/apache/datafusion/pull/22244#discussion_r3292066197
##########
datafusion/functions/src/string/concat.rs:
##########
@@ -67,27 +68,19 @@ impl Default for ConcatFunc {
impl ConcatFunc {
pub fn new() -> Self {
- use DataType::*;
Self {
- signature: Signature::variadic(
- vec![Utf8View, Utf8, LargeUtf8, Binary],
- Volatility::Immutable,
- ),
+ // Use `Signature::UserDefined` to allow different argument types.
+ // `Variadic` requires every argument to be coerced to the same
string type,
+ // so the UDF cannot distinguish between binary and string inputs.
+ signature: Signature::user_defined(Volatility::Immutable),
}
}
}
-fn deduce_return_type(arg_types: &[DataType]) -> DataType {
- use DataType::*;
- if arg_types.contains(&Utf8View) {
- Utf8View
- } else if arg_types.contains(&LargeUtf8) {
- LargeUtf8
- } else {
- Utf8
- }
-}
-
+// Logic is matched with pipe operator in the following table.
+// Support only string + string concatenation,
+// or binary + binary concatenation.
+// Mixed string + binary concatenation is rejected,
Review Comment:
I think this might constitute a breaking change 🤔
##########
datafusion/expr/src/type_coercion/mod.rs:
##########
@@ -75,3 +75,20 @@ pub fn is_datetime(dt: &DataType) -> bool {
DataType::Date32 | DataType::Date64 | DataType::Timestamp(_, _)
)
}
+
Review Comment:
We have
[`DataType::is_string`](https://docs.rs/arrow/latest/arrow/datatypes/enum.DataType.html#method.is_string)
and
[`DataType::is_binary`](https://docs.rs/arrow/latest/arrow/datatypes/enum.DataType.html#method.is_binary)
we can use
--
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]