Skip to content

Commit

Permalink
update reserved properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses-you committed Jun 24, 2020
1 parent 1edc619 commit 78ff34f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -839,18 +839,24 @@ case class AlterTableSetLocationCommand(
object DDLUtils {
val HIVE_PROVIDER = "hive"

val METASTORE_GENERATED_PROPERTIES: Set[String] = Set(
val RESERVED_PROPERTIES: Set[String] =
// spark reserved properties
Set(
TableCatalog.PROP_COMMENT,
TableCatalog.PROP_LOCATION,
TableCatalog.PROP_OWNER,
TableCatalog.PROP_PROVIDER) ++
// hive reserved properties
Set(
"CreateTime",
"transient_lastDdlTime",
"grantTime",
"lastUpdateTime",
"last_modified_by",
"last_modified_time",
"Owner:",
"totalNumberFiles",
"maxFileSize",
"minFileSize"
)
"minFileSize")

def isHiveTable(table: CatalogTable): Boolean = {
isHiveTable(table.provider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ case class CreateTableLikeCommand(
case MANAGED | EXTERNAL =>
// Hive only retain the useful properties through serde class annotation.
// For better compatible with Hive, we remove the metastore properties.
sourceTableDesc.properties -- DDLUtils.METASTORE_GENERATED_PROPERTIES ++ properties
sourceTableDesc.properties -- DDLUtils.RESERVED_PROPERTIES ++ properties
case VIEW =>
// For view, we just use new properties
properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2727,7 +2727,7 @@ class HiveDDLSuite

test("SPARK-31828: Filters out Hive metastore properties in CreateTableLikeCommand") {
val catalog = spark.sessionState.catalog
DDLUtils.METASTORE_GENERATED_PROPERTIES.foreach { meta =>
DDLUtils.RESERVED_PROPERTIES.foreach { meta =>
withTable("t1", "t2") {
val uuid = UUID.randomUUID().toString
sql(s"CREATE TABLE t1(c1 int) TBLPROPERTIES('$meta'='$uuid')")
Expand Down

0 comments on commit 78ff34f

Please sign in to comment.