Skip to content

Conversation

@gatorsmile
Copy link
Member

@gatorsmile gatorsmile commented May 6, 2016

What changes were proposed in this pull request?

In Hive Metastore, dropping default database is not allowed. However, in InMemoryCatalog, this is allowed.

This PR is to disallow users to drop default database.

How was this patch tested?

Previously, we already have a test case in HiveDDLSuite. Now, we also add the same one in DDLSuite

@SparkQA
Copy link

SparkQA commented May 6, 2016

Test build #58015 has finished for PR 12962 at commit 20ebf8a.

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

@gatorsmile
Copy link
Member Author

cc @yhuai @andrewor14 @cloud-fan

}

def dropDatabase(db: String, ignoreIfNotExists: Boolean, cascade: Boolean): Unit = {
if (db == "default") {
Copy link
Contributor

@cloud-fan cloud-fan May 7, 2016

Choose a reason for hiding this comment

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

how about case sensitivity?

Copy link
Member Author

@gatorsmile gatorsmile May 7, 2016

Choose a reason for hiding this comment

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

You are asking a very great question! Actually, I am not very sure how it works.

First, the current code base is not considering case sensitivity in database names. That part is missing. I think we should create another function like what the function formatTableName is doing for all the cases. For example, formatDatabaseName.

Second, I saw we have a function formatTableName for formatting table names based on the configuration of CASE_SENSITIVE. However, the underlying Hive metastore is not case sensitive. See the document: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL

My question is how to achieve the case sensitivity when using Hive metastore? also cc @yhuai

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Now, I think we should issue an exception if users set CASE_SENSITIVE to true if users use Hive Metastore.

Copy link
Member Author

Choose a reason for hiding this comment

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

So far, the best way I found is to override caseSensitiveAnalysis to false in conf of HiveSessionState.

  override lazy val conf: SQLConf = new SQLConf {
    override def caseSensitiveAnalysis: Boolean = false
  }

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me submit a PR to fix it. : )

@SparkQA
Copy link

SparkQA commented May 7, 2016

Test build #58072 has finished for PR 12962 at commit 67c2ebc.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member Author

@cloud-fan #12993 resolves the issue you mentioned above. Will change this PR too for resolving the issues of database names by calling formatDatabaseName

Thanks!

@andrewor14
Copy link
Contributor

retest this please

@andrewor14
Copy link
Contributor

LGTM

@gatorsmile
Copy link
Member Author

To fix the test failure, we need to call formatDatabaseName on the database name in all the SessionCatalog and HiveSessionCatalog APIs. Will do it this afternoon. Thanks!

@SparkQA
Copy link

SparkQA commented May 9, 2016

Test build #58150 has finished for PR 12962 at commit 67c2ebc.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 10, 2016

Test build #58179 has finished for PR 12962 at commit 87099f1.

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

@gatorsmile
Copy link
Member Author

@andrewor14 @cloud-fan The PR is ready for review. Thanks!

asfgit pushed a commit that referenced this pull request May 10, 2016
#### What changes were proposed in this pull request?
In Hive Metastore, dropping default database is not allowed. However, in `InMemoryCatalog`, this is allowed.

This PR is to disallow users to drop default database.

#### How was this patch tested?
Previously, we already have a test case in HiveDDLSuite. Now, we also add the same one in DDLSuite

Author: gatorsmile <[email protected]>

Closes #12962 from gatorsmile/dropDefaultDB.

(cherry picked from commit f453791)
Signed-off-by: Wenchen Fan <[email protected]>
@cloud-fan
Copy link
Contributor

LGTM , merging to master and 2.0, thanks!

@asfgit asfgit closed this in f453791 May 10, 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