wangyum opened a new pull request #25261: [SPARK-28521][SQL] Fix error message for built-in functions URL: https://github.com/apache/spark/pull/25261 ## What changes were proposed in this pull request? ```sql spark-sql> select cast(1); 19/07/26 00:54:17 ERROR SparkSQLDriver: Failed in [select cast(1)] java.lang.UnsupportedOperationException: empty.init at scala.collection.TraversableLike$class.init(TraversableLike.scala:451) at scala.collection.mutable.ArrayOps$ofInt.scala$collection$IndexedSeqOptimized$$super$init(ArrayOps.scala:234) at scala.collection.IndexedSeqOptimized$class.init(IndexedSeqOptimized.scala:135) at scala.collection.mutable.ArrayOps$ofInt.init(ArrayOps.scala:234) at org.apache.spark.sql.catalyst.analysis.FunctionRegistry$$anonfun$7$$anonfun$11.apply(FunctionRegistry.scala:565) at org.apache.spark.sql.catalyst.analysis.FunctionRegistry$$anonfun$7$$anonfun$11.apply(FunctionRegistry.scala:558) at scala.Option.getOrElse(Option.scala:121) ``` The reason is [parameter types](https://github.com/apache/spark/blob/832ff8791807874bf5c09075295e760ab67833eb/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala#L585) can be `Expression`, `DataType` and `Option`. This PR makes the constructor allow to include the `DataType`. But we still do not allow `Option` because Option is usually not available in SQL interface: ```sql spark-sql> SELECT from_unixtime(0, 'yyyy-MM-dd HH:mm:ss', 'timeZoneId'); Error in query: Invalid number of arguments for function from_unixtime. Expected: one of 1 and 2; Found: 3; line 1 pos 7 ``` ## How was this patch tested? unit tests
---------------------------------------------------------------- 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]
