@@ -493,13 +493,43 @@ core::PlanNodePtr SubstraitToVeloxPlanConverter::toVeloxPlan(const ::substrait::
493
493
}
494
494
}
495
495
496
+ std::string makeUuid () {
497
+ return boost::lexical_cast<std::string>(boost::uuids::random_generator ()());
498
+ }
499
+
500
+ std::string compressionFileNameSuffix (common::CompressionKind kind) {
501
+ switch (static_cast <int32_t >(kind)) {
502
+ case common::CompressionKind_ZLIB:
503
+ return " .zlib" ;
504
+ case common::CompressionKind_SNAPPY:
505
+ return " .snappy" ;
506
+ case common::CompressionKind_LZO:
507
+ return " .lzo" ;
508
+ case common::CompressionKind_ZSTD:
509
+ return " .zstd" ;
510
+ case common::CompressionKind_LZ4:
511
+ return " .lz4" ;
512
+ case common::CompressionKind_GZIP:
513
+ return " .gz" ;
514
+ case common::CompressionKind_NONE:
515
+ default :
516
+ return " " ;
517
+ }
518
+ }
519
+
496
520
std::shared_ptr<connector::hive::LocationHandle> makeLocationHandle (
497
521
const std::string& targetDirectory,
522
+ dwio::common::FileFormat fileFormat,
523
+ common::CompressionKind compression,
498
524
const std::optional<std::string>& writeDirectory = std::nullopt,
499
525
const connector::hive::LocationHandle::TableType& tableType =
500
526
connector::hive::LocationHandle::TableType::kExisting ) {
527
+ std::string targetFileName = " " ;
528
+ if (fileFormat == dwio::common::FileFormat::PARQUET) {
529
+ targetFileName = fmt::format (" gluten-part-{}{}{}" , makeUuid (), compressionFileNameSuffix (compression), " .parquet" );
530
+ }
501
531
return std::make_shared<connector::hive::LocationHandle>(
502
- targetDirectory, writeDirectory.value_or (targetDirectory), tableType);
532
+ targetDirectory, writeDirectory.value_or (targetDirectory), tableType, targetFileName );
503
533
}
504
534
505
535
std::shared_ptr<connector::hive::HiveInsertTableHandle> makeHiveInsertTableHandle (
@@ -615,6 +645,8 @@ core::PlanNodePtr SubstraitToVeloxPlanConverter::toVeloxPlan(const ::substrait::
615
645
616
646
// Do not hard-code connector ID and allow for connectors other than Hive.
617
647
static const std::string kHiveConnectorId = " test-hive" ;
648
+ // Currently only support parquet format.
649
+ dwio::common::FileFormat fileFormat = dwio::common::FileFormat::PARQUET;
618
650
619
651
return std::make_shared<core::TableWriteNode>(
620
652
nextPlanNodeId (),
@@ -628,8 +660,8 @@ core::PlanNodePtr SubstraitToVeloxPlanConverter::toVeloxPlan(const ::substrait::
628
660
inputType->children (),
629
661
partitionedKey,
630
662
nullptr /* bucketProperty*/ ,
631
- makeLocationHandle (writePath),
632
- dwio::common::FileFormat::PARQUET, // Currently only support parquet format.
663
+ makeLocationHandle (writePath, fileFormat, compressionCodec ),
664
+ fileFormat,
633
665
compressionCodec)),
634
666
(!partitionedKey.empty ()),
635
667
exec::TableWriteTraits::outputType (nullptr ),
0 commit comments