Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/11349#discussion_r54055804
--- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
@@ -542,7 +542,14 @@
https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C
case Token("TOK_DROPTABLE",
Token("TOK_TABNAME", tableNameParts) ::
ifExists) =>
- val tableName = tableNameParts.map { case Token(p, Nil) => p
}.mkString(".")
+ // Hive's parser will unquote an identifier (see the rule of
QuotedIdentifier in
+ // HiveLexer.g of Hive 1.2.1). So, we will quote a table name part
if it starts with
+ // underscore (_). Please note that although QuotedIdentifier rule
allows backticks
+ // appearing in an identifier, Hive does not actually allow such an
identifier be
+ // a table name. So, we
+ val tableName = tableNameParts.map {
+ case Token(p, Nil) => if (p.startsWith("_")) s"`$p`" else p
+ }.mkString(".")
--- End diff --
`DropTable` also tries to unregister temporary tables of the same name
using:
```scala
hiveContext.catalog.unregisterTable(TableIdentifier(tableName))
````
Now the `tableName` argument of `DropTable` is quoted when it's started
with `_`, but `TableIdentifier` doesn't parse and unquote the table name. Thus
the temporary table can't be dropped in this case.
Another problem of the above line is that, `DropTable.tableName` can be the
form of `db.table`, but we throw the whole string into `TableIdentifier`
without splitting them. But that's another bug.
---
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]