@@ -69,7 +69,8 @@ std::unique_ptr<dwio::common::FileSink> createHiveFileSink(
6969 const std::shared_ptr<const HiveConfig>& hiveConfig,
7070 memory::MemoryPool* sinkPool,
7171 io::IoStatistics* ioStats,
72- IoStats* fileSystemStats) {
72+ IoStats* fileSystemStats,
73+ const std::unordered_map<std::string, std::string>& tableParameters) {
7374 return dwio::common::FileSink::create (
7475 path,
7576 {
@@ -80,6 +81,7 @@ std::unique_ptr<dwio::common::FileSink> createHiveFileSink(
8081 .metricLogger = dwio::common::MetricsLog::voidLog (),
8182 .stats = ioStats,
8283 .fileSystemStats = fileSystemStats,
84+ .tableParameters = tableParameters,
8385 });
8486}
8587
@@ -429,7 +431,8 @@ HiveInsertTableHandle::HiveInsertTableHandle(
429431 // if there's no data. This is useful when the table is bucketed, but the
430432 // engine handles ensuring a 1 to 1 mapping from task to bucket.
431433 const bool ensureFiles,
432- std::shared_ptr<const FileNameGenerator> fileNameGenerator)
434+ std::shared_ptr<const FileNameGenerator> fileNameGenerator,
435+ const std::unordered_map<std::string, std::string>& tableParameters)
433436 : inputColumns_(std::move(inputColumns)),
434437 locationHandle_(std::move(locationHandle)),
435438 storageFormat_(storageFormat),
@@ -439,6 +442,7 @@ HiveInsertTableHandle::HiveInsertTableHandle(
439442 writerOptions_(writerOptions),
440443 ensureFiles_(ensureFiles),
441444 fileNameGenerator_(std::move(fileNameGenerator)),
445+ tableParameters_(tableParameters),
442446 partitionChannels_(computePartitionChannels(inputColumns_)),
443447 nonPartitionChannels_(computeNonPartitionChannels(inputColumns_)) {
444448 if (compressionKind.has_value ()) {
@@ -1076,7 +1080,8 @@ std::unique_ptr<dwio::common::Writer> HiveDataSink::createWriterForIndex(
10761080 hiveConfig_,
10771081 info->sinkPool .get (),
10781082 ioStats_[writerIndex].get (),
1079- fileSystemStats_.get ()),
1083+ fileSystemStats_.get (),
1084+ insertTableHandle_->tableParameters ()),
10801085 options);
10811086 return maybeCreateBucketSortWriter (writerIndex, std::move (writer));
10821087}
@@ -1358,6 +1363,13 @@ folly::dynamic HiveInsertTableHandle::serialize() const {
13581363 params[key] = value;
13591364 }
13601365 obj[" serdeParameters" ] = params;
1366+
1367+ folly::dynamic tableParams = folly::dynamic::object;
1368+ for (const auto & [key, value] : tableParameters_) {
1369+ tableParams[key] = value;
1370+ }
1371+ obj[" tableParameters" ] = tableParams;
1372+
13611373 obj[" ensureFiles" ] = ensureFiles_;
13621374 obj[" fileNameGenerator" ] = fileNameGenerator_->serialize ();
13631375 return obj;
@@ -1389,6 +1401,13 @@ HiveInsertTableHandlePtr HiveInsertTableHandle::create(
13891401 serdeParameters.emplace (pair.first .asString (), pair.second .asString ());
13901402 }
13911403
1404+ std::unordered_map<std::string, std::string> tableParameters;
1405+ if (obj.count (" tableParameters" ) > 0 ) {
1406+ for (const auto & pair : obj[" tableParameters" ].items ()) {
1407+ tableParameters.emplace (pair.first .asString (), pair.second .asString ());
1408+ }
1409+ }
1410+
13921411 bool ensureFiles = obj[" ensureFiles" ].asBool ();
13931412
13941413 auto fileNameGenerator =
@@ -1402,7 +1421,8 @@ HiveInsertTableHandlePtr HiveInsertTableHandle::create(
14021421 serdeParameters,
14031422 nullptr , // writerOptions is not serializable
14041423 ensureFiles,
1405- fileNameGenerator);
1424+ fileNameGenerator,
1425+ tableParameters);
14061426}
14071427
14081428void HiveInsertTableHandle::registerSerDe () {
0 commit comments