Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/15677
  
    > However, the complex type we should block. We also need to fix it in the 
code.
    
    It does not support complex types already but only `AtomicType`[1].
    
    ```
    spark-sql> SELECT reverse(array(1));
    Error in query: cannot resolve 'reverse(array(1))' due to data type 
mismatch: argument 1 requires string type, however, 'array(1)' is of array<int> 
type.; line 1 pos 7;
    'Project [unresolvedalias(reverse(array(1)), None)]
    +- OneRowRelation$
    
    spark-sql> SELECT reverse(map(1, 1));
    Error in query: cannot resolve 'reverse(map(1, 1))' due to data type 
mismatch: argument 1 requires string type, however, 'map(1, 1)' is of 
map<int,int> type.; line 1 pos 7;
    'Project [unresolvedalias(reverse(map(1, 1)), None)]
    +- OneRowRelation$
    
    spark-sql> SELECT reverse(struct(1, 1));
    Error in query: cannot resolve 'reverse(struct(1, 1))' due to data type 
mismatch: argument 1 requires string type, however, 'struct(1, 1)' is of 
struct<col1:int,col2:int> type.; line 1 pos 7;
    'Project [unresolvedalias(reverse(struct(1, 1)), None)]
    +- OneRowRelation$
    
    spark-sql> SELECT reverse(1);
    1
    Time taken: 0.049 seconds, Fetched 1 row(s)
    spark-sql> SELECT reverse(12);
    21
    Time taken: 0.053 seconds, Fetched 1 row(s)
    spark-sql> SELECT reverse(12.0D);
    0.21
    Time taken: 0.046 seconds, Fetched 1 row(s)
    spark-sql> SELECT reverse(12BD);
    21
    Time taken: 0.035 seconds, Fetched 1 row(s)
    spark-sql> SELECT reverse(12L);
    21
    Time taken: 0.034 seconds, Fetched 1 row(s)
    spark-sql>
    ```
    
    
[1]https://github.com/apache/spark/blob/39e2bad6a866d27c3ca594d15e574a1da3ee84cc/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala#L685-L720


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to