Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class SessionCatalog(
}

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

@cloud-fan cloud-fan May 7, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how about case sensitivity?

@gatorsmile gatorsmile May 7, 2016

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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. : )

throw new AnalysisException(s"Can not drop default database")
}
externalCatalog.dropDatabase(db, ignoreIfNotExists, cascade)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -939,4 +939,11 @@ class DDLSuite extends QueryTest with SharedSQLContext with BeforeAndAfterEach {
Row("Usage: a ^ b - Bitwise exclusive OR.") :: Nil
)
}

test("drop default database") {
val message = intercept[AnalysisException] {
sql("DROP DATABASE default")
}.getMessage
assert(message.contains("Can not drop default database"))
}
}