jonahgao commented on code in PR #10044:
URL: 
https://github.com/apache/arrow-datafusion/pull/10044#discussion_r1564097115


##########
datafusion/sqllogictest/test_files/unnest.slt:
##########
@@ -136,8 +150,43 @@ query error DataFusion error: Error during planning: 
unnest\(\) can only be appl
 select unnest(column3) from unnest_table;
 
 ## Multiple unnest functions in selection
-query error DataFusion error: This feature is not implemented: Only support 
single unnest expression for now
-select unnest(column1), unnest(column2) from unnest_table;
+query ?I
+select unnest([]), unnest(NULL::int[]);

Review Comment:
   I'm not sure how to support it yet.  PostgreSQL, BigQuery, and Clickhouse 
don't support unnesting untyped NULLs.
   ```sh
   postgres=# select unnest(NULL);
   ERROR:  function unnest(unknown) is not unique
   LINE 1: select unnest(NULL);
                  ^
   HINT:  Could not choose a best candidate function. You might need to add 
explicit type casts.
   ```
   Although DuckDB supports it, its behavior seems a bit strange to me.
   ```sh
   D select unnest(NULL), unnest([1,2]);
   ┌──────────────┬───────────────────────────────┐
   │ unnest(NULL) │ unnest(main.list_value(1, 2)) │
   │    int32     │             int32             │
   ├──────────────────────────────────────────────┤
   │                    0 rows                    │
   └──────────────────────────────────────────────┘
   D select unnest(NULL::int[]), unnest([1,2]);
   ┌─────────────────────────────────┬───────────────────────────────┐
   │ unnest(CAST(NULL AS INTEGER[])) │ unnest(main.list_value(1, 2)) │
   │              int32              │             int32             │
   ├─────────────────────────────────┼───────────────────────────────┤
   │                                 │                             1 │
   │                                 │                             2 │
   └─────────────────────────────────┴───────────────────────────────┘
   ```
   Unnesting an untyped NULL  and a typed NULL produced different results.
   
   I think there may be two appropriate methods:
   1. Use type coercion to convert an untype NULL into a certain List type like 
`cast(NULL, NULL::int[])`.
   2. Explicitly reject unnesting untyped NULLs.
   



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

Reply via email to