Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12537#discussion_r60791101
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/TableIdentifierParserSuite.scala
 ---
    @@ -30,13 +64,22 @@ class TableIdentifierParserSuite extends SparkFunSuite {
         // Illegal names.
         intercept[ParseException](parseTableIdentifier(""))
         intercept[ParseException](parseTableIdentifier("d.q.g"))
    +  }
     
    +  test("table identifier - keywords") {
         // SQL Keywords.
    -    val keywords = Seq("select", "from", "where", "left", "right")
    +    val keywords = Seq("select", "from", "where") ++ 
hiveNonReservedRegression
         keywords.foreach { keyword =>
           intercept[ParseException](parseTableIdentifier(keyword))
           assert(TableIdentifier(keyword) === 
parseTableIdentifier(s"`$keyword`"))
           assert(TableIdentifier(keyword, Option("db")) === 
parseTableIdentifier(s"db.`$keyword`"))
         }
       }
    +
    +  test("table identifier - non reserved keywords") {
    +    // Hive keywords are allowed.
    +    hiveNonReservedKeyword.foreach { nonReserved =>
    +      assert(TableIdentifier(nonReserved) === 
parseTableIdentifier(nonReserved))
    +    }
    +  }
    --- End diff --
    
    In the current Parser, we still have another issue. For example, our Parser 
can accept 
    ```
    CREATE TABLE `tab:1`  ...
    ```
    However, Hive metastore does not allow it. We hit an exception from the 
metastore:
    ```
    org.apache.hadoop.hive.ql.metadata.HiveException: 
org.apache.hadoop.hive.ql.metadata.HiveException: [tab:1]: is not a valid table 
name;
    org.apache.spark.sql.AnalysisException: 
org.apache.hadoop.hive.ql.metadata.HiveException: 
org.apache.hadoop.hive.ql.metadata.HiveException: [tab:1]: is not a valid table 
name;
        at 
org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:71)
        at 
org.apache.spark.sql.hive.HiveExternalCatalog.createTable(HiveExternalCatalog.scala:147)
        at 
org.apache.spark.sql.catalyst.catalog.SessionCatalog.createTable(SessionCatalog.scala:188)
    ```
    In the next PR, I will add the extra logics to verify the names before 
calling Hive metastore APIs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to