Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-22553

Drop FROM in nonReserved

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Incomplete
    • 2.2.0
    • None
    • SQL

    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

        Issue Links

          Activity

            People

              Unassigned Unassigned
              maropu Takeshi Yamamuro
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: