jayzhan211 commented on code in PR #10268:
URL: https://github.com/apache/datafusion/pull/10268#discussion_r1589198958


##########
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.
   
   For example,
   ```
   postgres=# select array[row(1, 'a'), 'b'];
   ERROR:  input of anonymous composite types is not implemented
   LINE 1: select array[row(1, 'a'), 'b'];
                                     ^
   postgres=# select array[row(1, 'a')::TEXT, 'b'];
       array    
   -------------
    {"(1,a)",b}
   (1 row)
   ```
   
   Given that the dictionary is converted to value type and **no longer a 
dictionary type anymore**, it is a special case for me.
   
   But, given it is already used heavily, as long as the behavior is 
well-defined, we don't need to strictly follow Postgres or DuckDB but keep it 
unchanged.
   
   Then, I have a question about this.
   Should we only special case with `coalesce`, or are there any other 
functions we need to care about?
   Like array, I think it is not heavily used (?), we can avoid converting dict 
to value type for array.
   But, given that we have different coercion behavior between functions, I 
need to think about how to handle those cases 🤔 
   



-- 
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