HyukjinKwon opened a new pull request #27521: [SPARK-29462] The data type of 
"array()" should be array<null>
URL: https://github.com/apache/spark/pull/27521
 
 
   ### What changes were proposed in this pull request?
   
   This brings https://github.com/apache/spark/pull/26324 back. It was reverted 
basically because, firstly Hive compatibility, and the lack of investigations 
in other DBMSes and ANSI.
   
   - In case of PostgreSQL seems coercing NULL literal to TEXT type.
   - Presto seems coercing `array() + array(1)` -> array of int.
   - Hive seems  `array() + array(1)` -> array of strings
   
    Given that, the design choices have been differently made for some reasons. 
If we pick one of both, seems coercing to array of int makes much more sense.
   
   Another investigation was made offline internally. Seems ANSI "SQL 2011, 
section 6.5 "<contextually typed value specification>" states:
   
   > If ES is specified, then let ET be the element type determined by the 
context in which ES appears. The declared type DT of ES is Case:
   >
   > a) If ES simply contains ARRAY, then ET ARRAY[0].
   >
   > b) If ES simply contains MULTISET, then ET MULTISET.
   >
   > ES is effectively replaced by CAST ( ES AS DT )
   
   Assuming from the investigation made, choosing to `null` seems correct, and 
we have a reference Presto now.
   
   Therefore, this PR proposes to bring it back.
   
   ### Why are the changes needed?
   When empty array is created, it should be declared as array<null>.
   
   ### Does this PR introduce any user-facing change?
   Yes, `array()` creates `array<null>`
   
   ### How was this patch tested?
   Tested manually

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to