Skip to content

Commit

Permalink
fix some reveiw issue
Browse files Browse the repository at this point in the history
  • Loading branch information
windpiger committed Sep 23, 2019
1 parent fadc15c commit e168b34
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1084,9 +1084,9 @@ class SessionCatalog(
private def partitionWithQualifiedPath(
tableIdentifier: TableIdentifier,
parts: Seq[CatalogTablePartition]): Seq[CatalogTablePartition] = {
lazy val tbl = getTableMetadata(tableIdentifier)
parts.map { part =>
if (part.storage.locationUri.isDefined && !part.storage.locationUri.get.isAbsolute) {
val tbl = getTableMetadata(tableIdentifier)
val partPath = new Path(new Path(tbl.location), new Path(part.storage.locationUri.get))
val qualifiedPartPath = makeQualifiedPath(CatalogUtils.stringToURI(partPath.toString))
part.copy(storage = part.storage.copy(locationUri = Some(qualifiedPartPath)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2532,7 +2532,7 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
withTempDir { dir =>
spark.sql(
s"""
|CREATE TABLE t(a STRING, b STRING) USING parquet PARTITIONED BY(b) LOCATION '$dir'
|CREATE TABLE t(a STRING, b STRING) USING ${dataSource} PARTITIONED BY(b) LOCATION '$dir'
""".stripMargin)
spark.sql("INSERT INTO TABLE t PARTITION(b=1) SELECT 2")
val part = spark.sessionState.catalog.getPartition(TableIdentifier("t"), Map("b" -> "1"))
Expand All @@ -2543,7 +2543,6 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
withTempDir { dir =>
spark.sql(s"ALTER TABLE t PARTITION(b=1) SET LOCATION '$dir'")

val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t"))
val part = spark.sessionState.catalog.getPartition(TableIdentifier("t"), Map("b" -> "1"))
assert(part.storage.locationUri.contains(makeQualifiedPath(dir.getAbsolutePath)))
assert(part.storage.locationUri.get.toString.startsWith("file:/"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2133,38 +2133,7 @@ class HiveDDLSuite
}
}
}

test("the qualified path of a partition is stored in the catalog") {
withTable("t") {
withTempDir { dir =>
spark.sql(
s"""
|CREATE TABLE t(a STRING, b STRING) USING hive PARTITIONED BY(b) LOCATION '$dir'
""".stripMargin)
spark.sql("INSERT INTO TABLE t PARTITION(b=1) SELECT 2")
val part = spark.sessionState.catalog.getPartition(TableIdentifier("t"), Map("b" -> "1"))
assert(part.storage.locationUri.contains(
makeQualifiedPath(new File(dir, "b=1").getAbsolutePath)))
assert(part.storage.locationUri.get.toString.startsWith("file:/"))
}
withTempDir { dir =>
spark.sql(s"ALTER TABLE t PARTITION(b=1) SET LOCATION '$dir'")

val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t"))
val part = spark.sessionState.catalog.getPartition(TableIdentifier("t"), Map("b" -> "1"))
assert(part.storage.locationUri.contains(makeQualifiedPath(dir.getAbsolutePath)))
assert(part.storage.locationUri.get.toString.startsWith("file:/"))
}

withTempDir { dir =>
spark.sql(s"ALTER TABLE t ADD PARTITION(b=2) LOCATION '$dir'")
val part = spark.sessionState.catalog.getPartition(TableIdentifier("t"), Map("b" -> "2"))
assert(part.storage.locationUri.contains(makeQualifiedPath(dir.getAbsolutePath)))
assert(part.storage.locationUri.get.toString.startsWith("file:/"))
}
}
}


hiveFormats.foreach { tableType =>
test(s"alter hive serde table add columns -- partitioned - $tableType") {
withTable("tab") {
Expand Down

0 comments on commit e168b34

Please sign in to comment.