Skip to content

Conversation

@yhuai
Copy link
Contributor

@yhuai yhuai commented Feb 24, 2016

What changes were proposed in this pull request?

This change adds a workaround to allow users to drop a table with a name starting with an underscore. Without this patch, we can create such a table, but we cannot drop it. The reason is that Hive's parser unquote an quoted identifier (see https://github.com/apache/hive/blob/release-1.2.1/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g#L453). So, when we issue a drop table command to Hive, a table name starting with an underscore is actually not quoted. Then, Hive will complain about it because it does not support a table name starting with an underscore without using backticks (underscores are allowed as long as it is not the first char though).

How was this patch tested?

Add a test to make sure we can drop a table with a name starting with an underscore.

https://issues.apache.org/jira/browse/SPARK-13454

@yhuai
Copy link
Contributor Author

yhuai commented Feb 24, 2016

This PR is just for branch 1.6. Master does not have this problem.

@SparkQA
Copy link

SparkQA commented Feb 24, 2016

Test build #51889 has finished for PR 11349 at commit 70cfee0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment is incomplete...

@SparkQA
Copy link

SparkQA commented Feb 25, 2016

Test build #51923 has finished for PR 11349 at commit 3a8c9b8.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DropTable also tries to unregister temporary tables of the same name using:

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.

@yhuai
Copy link
Contributor Author

yhuai commented Feb 26, 2016

OK I have addressed the comments. I moved the fix to DropTable.

@SparkQA
Copy link

SparkQA commented Feb 26, 2016

Test build #52062 has finished for PR 11349 at commit dbddbe2.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Feb 26, 2016

Test build #52063 has finished for PR 11349 at commit ce05f8b.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@yhuai
Copy link
Contributor Author

yhuai commented Feb 26, 2016

Merging to 1.6

asfgit pushed a commit that referenced this pull request Feb 26, 2016
…ith an underscore.

## What changes were proposed in this pull request?

This change adds a workaround to allow users to drop a table with a name starting with an underscore. Without this patch, we can create such a table, but we cannot drop it. The reason is that Hive's parser unquote an quoted identifier (see https://github.com/apache/hive/blob/release-1.2.1/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g#L453). So, when we issue a drop table command to Hive, a table name starting with an underscore is actually not quoted. Then, Hive will complain about it because it does not support a table name starting with an underscore without using backticks (underscores are allowed as long as it is not the first char though).

## How was this patch tested?

Add a test to make sure we can drop a table with a name starting with an underscore.

https://issues.apache.org/jira/browse/SPARK-13454

Author: Yin Huai <[email protected]>

Closes #11349 from yhuai/fixDropTable.
@yhuai yhuai closed this Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants