Skip to content
Merged
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
3 changes: 3 additions & 0 deletions cpp/src/arrow/extension_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class ARROW_EXPORT ExtensionType : public DataType {

std::string name() const override { return "extension"; }

int32_t byte_width() const override { return storage_type_->byte_width(); }
int bit_width() const override { return storage_type_->bit_width(); }

/// \brief Unique name of extension type used to identify type for
/// serialization
/// \return the string name of the extension
Expand Down
5 changes: 5 additions & 0 deletions cpp/src/arrow/extension_type_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ TEST_F(TestExtensionType, ExtensionTypeTest) {

auto type = uuid();
ASSERT_EQ(type->id(), Type::EXTENSION);
ASSERT_EQ(type->bit_width(), 128);
ASSERT_EQ(type->byte_width(), 16);

const auto& ext_type = static_cast<const ExtensionType&>(*type);
std::string serialized = ext_type.Serialize();
Expand All @@ -204,6 +206,9 @@ TEST_F(TestExtensionType, ExtensionTypeTest) {
ext_type.Deserialize(fixed_size_binary(16), serialized));
ASSERT_TRUE(deserialized->Equals(*type));
ASSERT_FALSE(deserialized->Equals(*fixed_size_binary(16)));
ASSERT_EQ(deserialized->id(), Type::EXTENSION);
ASSERT_EQ(deserialized->bit_width(), 128);
ASSERT_EQ(deserialized->byte_width(), 16);
}

auto RoundtripBatch = [](const std::shared_ptr<RecordBatch>& batch,
Expand Down