[ 
https://issues.apache.org/jira/browse/SPARK-20171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16198719#comment-16198719
 ] 

Hyukjin Kwon commented on SPARK-20171:
--------------------------------------

I happen to look at this JIRA. Looks we now throw a different exception now:

{code}
scala> sql("SELECT cast(id, INT) FROM range(1)").queryExecution.analyzed
org.apache.spark.sql.AnalysisException: cannot resolve '`INT`' given input 
columns: [id]; line 1 pos 16;
'Project [unresolvedalias('cast(id#1L, 'INT), None)]
+- Range (0, 1, step=1, splits=None)
{code}

> Analyzer should include the arity of a function when reporting 
> "AnalysisException: Undefined function"
> ------------------------------------------------------------------------------------------------------
>
>                 Key: SPARK-20171
>                 URL: https://issues.apache.org/jira/browse/SPARK-20171
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 2.2.0
>            Reporter: Jacek Laskowski
>            Priority: Minor
>
> {{Analyzer}} reports {{AnalysisException}} when the arity of the function to 
> be looked up is incorrect.
> The following {{AnalysisException}} was because the arity of {{cast}} was 2 
> (not 1), but it said {{cast}} was not available which is only partially 
> correct. It'd be much more helpful to say something like {{"Undefined 
> function: 'cast' with 2 params"}}.
> Hint: It'd be even nicer if the exception included candidates like: {{Did you 
> mean "cast with 1 param"?}}
> {code}
> scala> sql("SELECT cast(id, INT) FROM range(1)").queryExecution.analyzed
> org.apache.spark.sql.AnalysisException: Undefined function: 'cast'. This 
> function is neither a registered temporary function nor a permanent function 
> registered in the database 'default'.; line 1 pos 7
>   at 
> org.apache.spark.sql.catalyst.analysis.Analyzer$LookupFunctions$$anonfun$apply$13$$anonfun$applyOrElse$44.apply(Analyzer.scala:1130)
>   at 
> org.apache.spark.sql.catalyst.analysis.Analyzer$LookupFunctions$$anonfun$apply$13$$anonfun$applyOrElse$44.apply(Analyzer.scala:1130)
>   at 
> org.apache.spark.sql.catalyst.analysis.package$.withPosition(package.scala:48)
>   at 
> org.apache.spark.sql.catalyst.analysis.Analyzer$LookupFunctions$$anonfun$apply$13.applyOrElse(Analyzer.scala:1129)
>   at 
> org.apache.spark.sql.catalyst.analysis.Analyzer$LookupFunctions$$anonfun$apply$13.applyOrElse(Analyzer.scala:1127)
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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

Reply via email to