Skip to content

Commit 3450f1c

Browse files
committed
Set specVersion in toThrift
1 parent a518a59 commit 3450f1c

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

cpp/src/generated/parquet_types.cpp

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cpp/src/generated/parquet_types.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cpp/src/parquet/parquet.thrift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ struct BsonType {
410410
struct VariantType {
411411
// The version of the variant specification that the variant was
412412
// written with.
413-
1: optional i8 specification_version = 1
413+
1: optional i8 specification_version
414414
}
415415

416416
/** Edge interpolation algorithm for Geography logical type */

cpp/src/parquet/schema_test.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,11 +2357,12 @@ TEST(TestLogicalTypeSerialization, Roundtrips) {
23572357
}
23582358

23592359
TEST(TestLogicalTypeSerialization, VariantSpecificationVersion) {
2360-
// Confirm that Variant logical type sets specification_version to 1 in thrift serialization
2360+
// Confirm that Variant logical type sets specification_version to 1 in thrift
2361+
// serialization
23612362
auto metadata = PrimitiveNode::Make("metadata", Repetition::REQUIRED, Type::BYTE_ARRAY);
23622363
auto value = PrimitiveNode::Make("value", Repetition::REQUIRED, Type::BYTE_ARRAY);
2363-
NodePtr variant_node = GroupNode::Make("variant", Repetition::REQUIRED, {metadata, value},
2364-
LogicalType::Variant());
2364+
NodePtr variant_node = GroupNode::Make("variant", Repetition::REQUIRED,
2365+
{metadata, value}, LogicalType::Variant());
23652366

23662367
std::vector<format::SchemaElement> elements;
23672368
ToParquet(reinterpret_cast<GroupNode*>(variant_node.get()), &elements);

cpp/src/parquet/types.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1959,12 +1959,20 @@ class LogicalType::Impl::Variant final : public LogicalType::Impl::Incompatible,
19591959
friend class VariantLogicalType;
19601960

19611961
OVERRIDE_TOSTRING(Variant)
1962-
OVERRIDE_TOTHRIFT(VariantType, VARIANT)
1962+
1963+
format::LogicalType ToThrift() const override {
1964+
format::LogicalType type;
1965+
format::VariantType variant_type;
1966+
variant_type.__set_specification_version(kSpecificationVersion);
1967+
type.__set_VARIANT(variant_type);
1968+
return type;
1969+
}
19631970

19641971
private:
19651972
Variant()
19661973
: LogicalType::Impl(LogicalType::Type::VARIANT, SortOrder::UNKNOWN),
19671974
LogicalType::Impl::Inapplicable() {}
1975+
static constexpr int8_t kSpecificationVersion = 1;
19681976
};
19691977

19701978
GENERATE_MAKE(Variant)

0 commit comments

Comments
 (0)