Skip to content
Closed
Show file tree
Hide file tree
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 @@ -1044,10 +1044,13 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
if (conf.convertCTAS && !hasStorageProperties) {
// At here, both rowStorage.serdeProperties and fileStorage.serdeProperties
// are empty Maps.
// For data source tables, table properties is only used to store schema and
// system-generated metadata. All user-specified properties/options will be stored
// in serde properties.
val optionsWithPath = if (location.isDefined) {
Map("path" -> location.get)
properties ++ Map("path" -> location.get)
} else {
Map.empty[String, String]
properties
}

val newTableDesc = tableDesc.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,20 @@ class HiveDDLSuite
}
}

test("CTAS - converted to Data Source Table but lost table properties") {
withSQLConf(SQLConf.CONVERT_CTAS.key -> "true") {
withTable("t") {
sql("CREATE TABLE t TBLPROPERTIES('prop1' = 'c', 'prop2' = 'd') AS SELECT 1 as a, 1 as b")
val tableDesc = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t"))
assert(tableDesc.properties.get("prop1").isEmpty)
assert(tableDesc.properties.get("prop2").isEmpty)
assert(tableDesc.storage.properties.get("prop1") == Option("c"))
assert(tableDesc.storage.properties.get("prop2") == Option("d"))
Copy link
Contributor

@cloud-fan cloud-fan Aug 20, 2016

Choose a reason for hiding this comment

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

is this what we want? Why do the table properties in Hive serde table should go to storage properties in data source table?

Ideally data source table should have data source options(storage properties) and table properties. Currently we don't support specifying table properties for data source tables, but it doesn't mean we will never do it. I think we can do it when unify the CREATE TABLE syntax.

Copy link
Member Author

Choose a reason for hiding this comment

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

uh, agree! Let me close this PR. Thanks!

checkAnswer(spark.table("t"), Row(1, 1) :: Nil)
}
}
}

test("desc table for data source table - partitioned bucketed table") {
withTable("t1") {
spark
Expand Down