Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-23000] Use fully qualified table names in HiveMetastoreCatalogSuite #20273

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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 @@ -166,13 +166,13 @@ class DataSourceWithHiveMetastoreCatalogSuite
))
).foreach { case (provider, (inputFormat, outputFormat, serde)) =>
test(s"Persist non-partitioned $provider relation into metastore as managed table") {
withTable("t") {
withTable("default.t") {
withSQLConf(SQLConf.PARQUET_WRITE_LEGACY_FORMAT.key -> "true") {
testDF
.write
.mode(SaveMode.Overwrite)
.format(provider)
.saveAsTable("t")
.saveAsTable("default.t")
}

val hiveTable = sessionState.catalog.getTableMetadata(TableIdentifier("t", Some("default")))
Expand All @@ -187,14 +187,15 @@ class DataSourceWithHiveMetastoreCatalogSuite
assert(columns.map(_.name) === Seq("d1", "d2"))
assert(columns.map(_.dataType) === Seq(DecimalType(10, 3), StringType))

checkAnswer(table("t"), testDF)
assert(sparkSession.metadataHive.runSqlHive("SELECT * FROM t") === Seq("1.1\t1", "2.1\t2"))
checkAnswer(table("default.t"), testDF)
assert(sparkSession.metadataHive.runSqlHive("SELECT * FROM default.t") ===
Seq("1.1\t1", "2.1\t2"))
}
}

test(s"Persist non-partitioned $provider relation into metastore as external table") {
withTempPath { dir =>
withTable("t") {
withTable("default.t") {
val path = dir.getCanonicalFile

withSQLConf(SQLConf.PARQUET_WRITE_LEGACY_FORMAT.key -> "true") {
Expand All @@ -203,7 +204,7 @@ class DataSourceWithHiveMetastoreCatalogSuite
.mode(SaveMode.Overwrite)
.format(provider)
.option("path", path.toString)
.saveAsTable("t")
.saveAsTable("default.t")
}

val hiveTable =
Expand All @@ -219,18 +220,18 @@ class DataSourceWithHiveMetastoreCatalogSuite
assert(columns.map(_.name) === Seq("d1", "d2"))
assert(columns.map(_.dataType) === Seq(DecimalType(10, 3), StringType))

checkAnswer(table("t"), testDF)
assert(sparkSession.metadataHive.runSqlHive("SELECT * FROM t") ===
checkAnswer(table("default.t"), testDF)
assert(sparkSession.metadataHive.runSqlHive("SELECT * FROM default.t") ===
Seq("1.1\t1", "2.1\t2"))
}
}
}

test(s"Persist non-partitioned $provider relation into metastore as managed table using CTAS") {
withTempPath { dir =>
withTable("t") {
withTable("default.t") {
sql(
s"""CREATE TABLE t USING $provider
s"""CREATE TABLE default.t USING $provider
|OPTIONS (path '${dir.toURI}')
|AS SELECT 1 AS d1, "val_1" AS d2
""".stripMargin)
Expand All @@ -248,8 +249,9 @@ class DataSourceWithHiveMetastoreCatalogSuite
assert(columns.map(_.name) === Seq("d1", "d2"))
assert(columns.map(_.dataType) === Seq(IntegerType, StringType))

checkAnswer(table("t"), Row(1, "val_1"))
assert(sparkSession.metadataHive.runSqlHive("SELECT * FROM t") === Seq("1\tval_1"))
checkAnswer(table("default.t"), Row(1, "val_1"))
assert(sparkSession.metadataHive.runSqlHive("SELECT * FROM default.t") ===
Seq("1\tval_1"))
}
}
}
Expand Down