jayzhan211 commented on code in PR #10268:
URL: https://github.com/apache/datafusion/pull/10268#discussion_r1593511241
##########
datafusion/sqllogictest/test_files/coalesce.slt:
##########
@@ -209,28 +209,20 @@ select
[3, 4] List(Field { name: "item", data_type: Int64, nullable: true, dict_id:
0, dict_is_ordered: false, metadata: {} })
# TODO: after switch signature of array to the same with coalesce, this query
should be fixed
-query ?T
+query error
select
coalesce(array[1, 2], array[arrow_cast(3, 'Int32'), arrow_cast(4, 'Int32')]),
arrow_typeof(coalesce(array[1, 2], array[arrow_cast(3, 'Int32'),
arrow_cast(4, 'Int32')]));
-----
-[1, 2] List(Field { name: "item", data_type: Int64, nullable: true, dict_id:
0, dict_is_ordered: false, metadata: {} })
statement ok
create table test1 as values (arrow_cast('foo', 'Dictionary(Int32, Utf8)')),
(null);
# Dictionary and String are not coercible
-query ?
+query error
Review Comment:
I recently met an similar issue in moving aggregate function where they have
their owned coercion rule, specifically `Sum` and `Avg`.
https://github.com/apache/datafusion/blob/96487ea0cbb7901a1e4aa18fdf6deb8961319fea/datafusion/expr/src/type_coercion/aggregates.rs#L108-L149
I think we need to have function-specific coercion. Introduce
TypeSignature::coercion, and it calls `fn coerce_types` for udf, udaf function
in `coerce_arguments_for_signature`. We can then have different coercion rule
for coalesce, make_array, sum, avg, and more. This not only solve the issue
above and also for UDAF. The user can define their coercion rule too.
What do you think? @alamb
--
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]