You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (Jira)" <ji...@apache.org> on 2020/03/23 05:00:00 UTC
[jira] [Commented] (SPARK-31194) spark sql runs successfully with
query not specifying condition next to where
[ https://issues.apache.org/jira/browse/SPARK-31194?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17064525#comment-17064525 ]
Hyukjin Kwon commented on SPARK-31194:
--------------------------------------
Seems like `WHERE` works as an alias of people. If you enable ANSI, it throws an errors properly:
{code}
scala> spark.conf.set("spark.sql.ansi.enabled", true)
scala> sql("select 1 from range(10) where").show()
org.apache.spark.sql.catalyst.parser.ParseException:
no viable alternative at input 'where'(line 1, pos 24)
== SQL ==
select 1 from range(10) where
------------------------^^^
at org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:263)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:130)
at org.apache.spark.sql.execution.SparkSqlParser.parse(SparkSqlParser.scala:49)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parsePlan(ParseDriver.scala:76)
at org.apache.spark.sql.SparkSession.$anonfun$sql$2(SparkSession.scala:604)
at org.apache.spark.sql.catalyst.QueryPlanningTracker.measurePhase(QueryPlanningTracker.scala:111)
at org.apache.spark.sql.SparkSession.$anonfun$sql$1(SparkSession.scala:604)
at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:763)
at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:601)
... 47 elided
{code}
{code}
scala> sql("select where.id from range(10) where").show()
+---+
| id|
+---+
| 0|
| 1|
| 2|
| 3|
| 4|
| 5|
| 6|
| 7|
| 8|
| 9|
+---+
{code}
> spark sql runs successfully with query not specifying condition next to where
> ------------------------------------------------------------------------------
>
> Key: SPARK-31194
> URL: https://issues.apache.org/jira/browse/SPARK-31194
> Project: Spark
> Issue Type: Story
> Components: SQL
> Affects Versions: 2.4.5
> Reporter: Ayoub Omari
> Priority: Major
>
> When having a sql query as follows:
> {color:#00875a}_SELECT *_{color}
> {color:#00875a}_FROM people_{color}
> {color:#00875a}_WHERE_{color}
> shouldn't we throw a parsing exception because of __unspecified _condition_ _?_
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org