alamb commented on code in PR #10268:
URL: https://github.com/apache/datafusion/pull/10268#discussion_r1594036090
##########
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:
> In Postgres, dictionary type (composite type including struct) is not
implicitly cast to another numeric type, so is DuckdDB.
It almost looks like those examples are using the term `Dictionary` in the
python sense (so more like an Arrow
[MapArray](https://docs.rs/arrow/latest/arrow/array/struct.MapArray.html#))
rather than an arrow DictionaryArray
> 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.
I think this makes a lot of sense and is a really good idea. Without it we
will basically end up trying to enumerate all possible coercion rules in the
datafusion core which is likely impossible
I will file a ticket
--
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]