GitHub user HyukjinKwon opened a pull request: https://github.com/apache/spark/pull/15532
[SPARK-17989][SQL] Check ascendingOrder type in sort_array function ahead ## What changes were proposed in this pull request? This PR proposes to check the second argument, `ascendingOrder` ahead not during execution with `ClassCastException` exception message. ```scala spark.range(1).selectExpr("array(1,2,3) as a").selectExpr("sort_array(a, 'a')").show() ``` **Before** ``` java.lang.ClassCastException: org.apache.spark.unsafe.types.UTF8String cannot be cast to java.lang.Boolean at scala.runtime.BoxesRunTime.unboxToBoolean(BoxesRunTime.java:85) at org.apache.spark.sql.catalyst.expressions.SortArray.nullSafeEval(collectionOperations.scala:185) at org.apache.spark.sql.catalyst.expressions.BinaryExpression.eval(Expression.scala:416) at org.apache.spark.sql.catalyst.optimizer.ConstantFolding$$anonfun$apply$1$$anonfun$applyOrElse$1.applyOrElse(expressions.scala:50) at org.apache.spark.sql.catalyst.optimizer.ConstantFolding$$anonfun$apply$1$$anonfun$applyOrElse$1.applyOrElse(expressions.scala:43) at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$3.apply(TreeNode.scala:292) at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$3.apply(TreeNode.scala:292) at org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:74) at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:291) at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformDown$1.apply(TreeNode.scala:297) **After** ``` Sort order in second argument requires boolean type, however, ''a'' is of string type.; ``` ## How was this patch tested? Unit test in `DataFrameFunctionsSuite`. You can merge this pull request into a Git repository by running: $ git pull https://github.com/HyukjinKwon/spark SPARK-17989 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/15532.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #15532 ---- commit 3437888819bfef501702367b3a38c813ae8e4067 Author: hyukjinkwon <gurwls...@gmail.com> Date: 2016-10-18T16:01:16Z Check ahead commit 5f7324580caa6bdbe1e658fe332c82c12aef9dbf Author: hyukjinkwon <gurwls...@gmail.com> Date: 2016-10-18T16:06:50Z Add a constant folding one in test just in case ---- --- 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