You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spark.apache.org by StanZhai <ma...@zhaishidan.cn> on 2017/02/06 12:41:44 UTC

[SQL]SQLParser fails to resolve nested CASE WHEN statement with parentheses in Spark 2.x

Hi all,

SQLParser fails to resolve nested CASE WHEN statement like this:

select case when
  (1) +
  case when 1>0 then 1 else 0 end = 2
then 1 else 0 end
from tb

==================== Exception ====================
Exception in thread "main"
org.apache.spark.sql.catalyst.parser.ParseException: 
mismatched input 'then' expecting {'.', '[', 'OR', 'AND', 'IN', NOT,
'BETWEEN', 'LIKE', RLIKE, 'IS', 'WHEN', EQ, '<=>', '<>', '!=', '<', LTE,
'>', GTE, '+', '-', '*', '/', '%', 'DIV', '&', '|', '^'}(line 5, pos 0)

== SQL ==

select case when
  (1) +
  case when 1>0 then 1 else 0 end = 2
then 1 else 0 end
^^^
from tb

But,remove parentheses will be fine:

select case when
  1 +
  case when 1>0 then 1 else 0 end = 2
then 1 else 0 end
from tb

I've already filed a JIRA for this: 
https://issues.apache.org/jira/browse/SPARK-19472
<https://issues.apache.org/jira/browse/SPARK-19472>  

Any help is greatly appreciated!

Best,
Stan




--
View this message in context: http://apache-spark-developers-list.1001551.n3.nabble.com/SQL-SQLParser-fails-to-resolve-nested-CASE-WHEN-statement-with-parentheses-in-Spark-2-x-tp20867.html
Sent from the Apache Spark Developers List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe e-mail: dev-unsubscribe@spark.apache.org


Re: [SQL]SQLParser fails to resolve nested CASE WHEN statement with parentheses in Spark 2.x

Posted by Herman van Hövell tot Westerflier <hv...@databricks.com>.
Hi Stan,

I have opened https://github.com/apache/spark/pull/16821 to fix this.

On Mon, Feb 6, 2017 at 1:41 PM, StanZhai <ma...@zhaishidan.cn> wrote:

> Hi all,
>
> SQLParser fails to resolve nested CASE WHEN statement like this:
>
> select case when
>   (1) +
>   case when 1>0 then 1 else 0 end = 2
> then 1 else 0 end
> from tb
>
> ==================== Exception ====================
> Exception in thread "main"
> org.apache.spark.sql.catalyst.parser.ParseException:
> mismatched input 'then' expecting {'.', '[', 'OR', 'AND', 'IN', NOT,
> 'BETWEEN', 'LIKE', RLIKE, 'IS', 'WHEN', EQ, '<=>', '<>', '!=', '<', LTE,
> '>', GTE, '+', '-', '*', '/', '%', 'DIV', '&', '|', '^'}(line 5, pos 0)
>
> == SQL ==
>
> select case when
>   (1) +
>   case when 1>0 then 1 else 0 end = 2
> then 1 else 0 end
> ^^^
> from tb
>
> But,remove parentheses will be fine:
>
> select case when
>   1 +
>   case when 1>0 then 1 else 0 end = 2
> then 1 else 0 end
> from tb
>
> I've already filed a JIRA for this:
> https://issues.apache.org/jira/browse/SPARK-19472
> <https://issues.apache.org/jira/browse/SPARK-19472>
>
> Any help is greatly appreciated!
>
> Best,
> Stan
>
>
>
>
> --
> View this message in context: http://apache-spark-
> developers-list.1001551.n3.nabble.com/SQL-SQLParser-
> fails-to-resolve-nested-CASE-WHEN-statement-with-parentheses-in-Spark-2-x-
> tp20867.html
> Sent from the Apache Spark Developers List mailing list archive at
> Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe e-mail: dev-unsubscribe@spark.apache.org
>
>


-- 


[image: Register today for Spark Summit East 2017!]
<https://spark-summit.org/east-2017/>

Herman van Hövell

Software Engineer

Databricks Inc.

hvanhovell@databricks.com

+31 6 420 590 27

databricks.com

[image: http://databricks.com] <http://databricks.com/>