[ 
https://issues.apache.org/jira/browse/SPARK-38130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Wenchen Fan resolved SPARK-38130.
---------------------------------
    Fix Version/s: 3.3.0
       Resolution: Fixed

Issue resolved by pull request 35426
[https://github.com/apache/spark/pull/35426]

> array_sort does not allow non-orderable datatypes
> -------------------------------------------------
>
>                 Key: SPARK-38130
>                 URL: https://issues.apache.org/jira/browse/SPARK-38130
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 3.2.1
>         Environment:  
>            Reporter: Steven Aerts
>            Assignee: Steven Aerts
>            Priority: Major
>             Fix For: 3.3.0
>
>
>  {{array_sort}} has check to see if the entries it has to sort are orderable.
> I think this check should be removed.  Because even entries which are not 
> orderable can have a lambda function which makes them orderable.
> {code:java}
> Seq((Array[Map[String, Int]](Map("a" -> 1), Map()), "x")).toDF("a", 
> "b").selectExpr("array_sort(a, (x,y) -> cardinality(x) - 
> cardinality(y))"){code}
> fails with:
> {code:java}
> org.apache.spark.sql.AnalysisException: cannot resolve 'array_sort(`a`, 
> lambdafunction((cardinality(namedlambdavariable()) - 
> cardinality(namedlambdavariable())), namedlambdavariable(), 
> namedlambdavariable()))' due to data type mismatch: array_sort does not 
> support sorting array of type map<string,int> which is not orderable {code}
> While the case where this check is relevant, fails with a different error 
> which is triggered earlier in the code path:
> {code:java}
> > Seq((Array[Map[String, Int]](Map("a" -> 1), Map()), "x")).toDF("a", 
> > "b").selectExpr("array_sort(a)"){code}
> Fails with:
> {code:java}
> org.apache.spark.sql.AnalysisException: cannot resolve 
> '(namedlambdavariable() < namedlambdavariable())' due to data type mismatch: 
> LessThan does not support ordering on type map<string,int>; line 1 pos 0;
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

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

Reply via email to