Skip to content

Commit ecacba7

Browse files
committed
SERDEPROPERTIES are missing when KSHC create table
1 parent a94cdda commit ecacba7

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

extensions/spark/kyuubi-spark-connector-hive/src/main/scala/org/apache/kyuubi/spark/connector/hive/HiveTableCatalog.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,12 @@ class HiveTableCatalog(sparkSession: SparkSession)
317317
val (partitionColumns, maybeBucketSpec) = partitions.toSeq.convertTransforms
318318
val location = Option(properties.get(TableCatalog.PROP_LOCATION))
319319
val maybeProvider = Option(properties.get(TableCatalog.PROP_PROVIDER))
320+
val tableProperties = properties.asScala.toMap
320321
val (storage, provider) =
321322
getStorageFormatAndProvider(
322323
maybeProvider,
323324
location,
324-
properties.asScala.toMap)
325-
val tableProperties = properties.asScala
325+
toOptions(tableProperties))
326326
val isExternal = properties.containsKey(TableCatalog.PROP_EXTERNAL)
327327
val tableType =
328328
if (isExternal || location.isDefined) {
@@ -339,7 +339,7 @@ class HiveTableCatalog(sparkSession: SparkSession)
339339
provider = Some(provider),
340340
partitionColumnNames = partitionColumns,
341341
bucketSpec = maybeBucketSpec,
342-
properties = tableProperties.toMap,
342+
properties = tableProperties,
343343
tracksPartitionsInCatalog = conf.manageFilesourcePartitions,
344344
comment = Option(properties.get(TableCatalog.PROP_COMMENT)))
345345

@@ -609,7 +609,7 @@ private object HiveTableCatalog extends Logging {
609609
outputFormat = hiveSerde.outputFormat.orElse(defaultHiveStorage.outputFormat),
610610
// User specified serde takes precedence over the one inferred from file format.
611611
serde = maybeSerde.orElse(hiveSerde.serde).orElse(defaultHiveStorage.serde),
612-
properties = options ++ defaultHiveStorage.properties)
612+
properties = defaultHiveStorage.properties)
613613
case _ => throw KyuubiHiveConnectorException(s"Unsupported serde ${maybeSerde.get}.")
614614
}
615615
} else {
@@ -619,7 +619,7 @@ private object HiveTableCatalog extends Logging {
619619
outputFormat =
620620
maybeOutputFormat.orElse(defaultHiveStorage.outputFormat),
621621
serde = maybeSerde.orElse(defaultHiveStorage.serde),
622-
properties = options ++ defaultHiveStorage.properties)
622+
properties = defaultHiveStorage.properties)
623623
}
624624
(storageFormat, DDLUtils.HIVE_PROVIDER)
625625
} else {

extensions/spark/kyuubi-spark-connector-hive/src/test/scala/org/apache/kyuubi/spark/connector/hive/HiveCatalogSuite.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,25 @@ class HiveCatalogSuite extends KyuubiHiveTest {
287287
catalog.dropTable(testIdent)
288288
}
289289

290+
test("createTable: SERDEPROPERTIES") {
291+
val properties = new util.HashMap[String, String]()
292+
properties.put("hive.serde", "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe")
293+
properties.put(TableCatalog.OPTION_PREFIX + "field.delim", ",")
294+
assert(!catalog.tableExists(testIdent))
295+
296+
val table = catalog.createTable(
297+
testIdent,
298+
schema,
299+
Array.empty[Transform],
300+
properties).asInstanceOf[HiveTable]
301+
302+
assert(!table.catalogTable.storage.properties.keys.exists(
303+
_.startsWith(TableCatalog.OPTION_PREFIX)))
304+
assert(!table.catalogTable.storage.properties.contains("hive.serde"))
305+
assert(table.catalogTable.storage.properties.contains("field.delim"))
306+
catalog.dropTable(testIdent)
307+
}
308+
290309
test("loadTable") {
291310
val table = catalog.createTable(testIdent, schema, Array.empty[Transform], emptyProps)
292311
val loaded = catalog.loadTable(testIdent)

0 commit comments

Comments
 (0)