Details
-
Improvement
-
Status: Resolved
-
Trivial
-
Resolution: Incomplete
-
2.2.0
-
None
Description
A simple query below throws a misleading error because nonReserved has `SELECT` in SqlBase.q4:
scala> Seq((1, 2)).toDF("a", "b").createTempView("t") scala> sql("select a, count(1), from t group by 1").show org.apache.spark.sql.AnalysisException: cannot resolve '`a`' given input columns: []; line 1 pos 7; 'Aggregate [unresolvedordinal(1)], ['a, count(1) AS count(1)#13L, 'from AS t#11] +- OneRowRelation$ at org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42) at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:88) at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:85) at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:289)
I know nonReserved currently has `SELECT` because of the historical reason (https://github.com/apache/spark/pull/18079#discussion_r118842186). But, since IMHO this is a kind of common mistakes (This message annoyed me a few days ago in large SQL queries...), it might be worth dropping it in the reserved.
FYI: In postgresql throws an explicit error in this case:
postgres=# select a, count(1), from test group by b; ERROR: syntax error at or near "from" at character 21 STATEMENT: select a, count(1), from test group by b; ERROR: syntax error at or near "from" LINE 1: select a, count(1), from test group by b;
Attachments
Attachments
Issue Links
- Is contained by
-
SPARK-26215 define reserved keywords after SQL standard
-
- Resolved
-