Github user jliwork commented on the pull request:
https://github.com/apache/spark/pull/9247#issuecomment-151030490
@cloud-fan Thanks for the clarification. You have a very good point. This
bug's exception occourred because SortArray's Comparators expect AtomicType
only. According to source code docs, AtomicType 'represent everything that is
not null, UDTs, arrays, structs, and maps'. My current fix takes care of
NullType only. StructType still causes execption, so you're right :-)
SortArray actually comes with checkInputDataTypes() which lets NullType and
StructType slip through because it uses RowOrdering.isOrderable which returns
true for AtomicType, NullType and StructType. I checked Hive's behavior for
struct type element. For example,
select sort_array(array(struct(3, 2, 1), struct(2, 3, 4))) from src
Hive does not support sort array with struct type involved. It returns
error for this query, saying function SORT_ARRAY must be array<PRIMITIVE>, but
array<struct<col1:int,col2:int,col3:int>> was found.
QUESTION - What do you expect the behavior of the query above for Spark
SQL? I would prefer to match with Hive's behavior which is to block this kind
of sorting on struct type elements since its use case does not seem very
meaningful to me.
Thanks,
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]