Skip to content

Commit

Permalink
remove uui-serialized string
Browse files Browse the repository at this point in the history
  • Loading branch information
rok committed Dec 12, 2023
1 parent 7b67150 commit 3e324bc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 26 deletions.
25 changes: 9 additions & 16 deletions cpp/src/arrow/c/bridge_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ static const std::string kEncodedUuidMetadata = // NOLINT: runtime/string
std::string {20, 0, 0, 0} + kExtensionTypeKeyName +
std::string {10, 0, 0, 0} + "arrow.uuid" +
std::string {24, 0, 0, 0} + kExtensionMetadataKeyName +
std::string {15, 0, 0, 0} + "uuid-serialized";
std::string {0, 0, 0, 0} + "";
#else
std::string {0, 0, 0, 2} +
std::string {0, 0, 0, 20} + kExtensionTypeKeyName +
std::string {0, 0, 0, 4} + "uuid" +
std::string {0, 0, 0, 10} + "arrow.uuid" +
std::string {0, 0, 0, 24} + kExtensionMetadataKeyName +
std::string {0, 0, 0, 15} + "uuid-serialized";
std::string {0, 0, 0, 0} + "";
#endif

static const std::string kEncodedDictExtensionMetadata = // NOLINT: runtime/string
Expand Down Expand Up @@ -2192,13 +2192,6 @@ TEST_F(TestSchemaImport, UnregisteredExtension) {
c_struct_.metadata = kEncodedUuidMetadata.c_str();
auto expected = uuid();
CheckImport(expected);

FillPrimitive(AddChild(), "u");
FillPrimitive("c");
FillDictionary();
c_struct_.metadata = kEncodedDictExtensionMetadata.c_str();
expected = dictionary(int8(), utf8());
CheckImport(expected);
}

TEST_F(TestSchemaImport, RegisteredExtension) {
Expand Down Expand Up @@ -2333,12 +2326,12 @@ TEST_F(TestSchemaImport, ExtensionError) {
c_struct_.metadata = kEncodedUuidMetadata.c_str();
CheckImportError();

// Invalid serialization
std::string bogus_metadata = kEncodedUuidMetadata;
bogus_metadata[bogus_metadata.size() - 5] += 1;
FillPrimitive("w:16");
c_struct_.metadata = bogus_metadata.c_str();
CheckImportError();
// // Invalid serialization
// std::string bogus_metadata = kEncodedUuidMetadata;
// bogus_metadata[bogus_metadata.size() - 5] += 1;
// FillPrimitive("w:16");
// c_struct_.metadata = bogus_metadata.c_str();
// CheckImportError();
}

TEST_F(TestSchemaImport, RecursionError) {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/extension/uuid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ std::shared_ptr<Array> UuidType::MakeArray(std::shared_ptr<ArrayData> data) cons

Result<std::shared_ptr<DataType>> UuidType::Deserialize(
std::shared_ptr<DataType> storage_type, const std::string& serialized) const {
if (serialized != "uuid-serialized") {
return Status::Invalid("Type identifier did not match: '", serialized, "'");
if (!serialized.empty()) {
return Status::Invalid("Unexpected serialized metadata: '", serialized, "'");
}
if (!storage_type->Equals(*fixed_size_binary(16))) {
return Status::Invalid("Invalid storage type for UuidType: ",
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/extension/uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ARROW_EXPORT UuidType : public ExtensionType {
std::shared_ptr<DataType> storage_type,
const std::string& serialized) const override;

std::string Serialize() const override { return "uuid-serialized"; }
std::string Serialize() const override { return ""; }

/// \brief Create a UuidType instance
static Result<std::shared_ptr<DataType>> Make() { return std::make_shared<UuidType>(); }
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/arrow/extension_type_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ TEST_F(TestExtensionType, UnrecognizedExtension) {
ASSERT_OK_AND_ASSIGN(auto complete_ipc_stream, out_stream->Finish());

ASSERT_OK(UnregisterExtensionType("arrow.uuid"));
auto ext_metadata =
key_value_metadata({{"ARROW:extension:name", "arrow.uuid"},
{"ARROW:extension:metadata", "uuid-serialized"}});
auto ext_metadata = key_value_metadata(
{{"ARROW:extension:name", "arrow.uuid"}, {"ARROW:extension:metadata", ""}});
auto ext_field = field("f0", fixed_size_binary(16), true, ext_metadata);
auto batch_no_ext = RecordBatch::Make(schema({ext_field}), 4, {storage_arr});

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/integration/json_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static const char* json_example2 = R"example(
"children" : [],
"metadata" : [
{"key": "ARROW:extension:name", "value": "arrow.uuid"},
{"key": "ARROW:extension:metadata", "value": "uuid-serialized"}
{"key": "ARROW:extension:metadata", "value": ""}
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions dev/archery/archery/integration/datagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1759,8 +1759,8 @@ def generate_nested_dictionary_case():
def generate_extension_case():
dict0 = Dictionary(0, StringField('dictionary0'), size=5, name='DICT0')

uuid_type = ExtensionType('arrow-uuid', '',
FixedSizeBinaryField('uuids', 16))
uuid_type = ExtensionType('arrow.uuid', '',
FixedSizeBinaryField('', 16))
dict_ext_type = ExtensionType(
'dict-extension', 'dict-extension-serialized',
DictionaryField('str_dict', get_field('', 'int8'), dict0))
Expand Down
2 changes: 1 addition & 1 deletion docs/source/format/Integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ FixedSizeBinary(16) storage, here is how a "uuid" field would be represented::
"children" : [],
"metadata" : [
{"key": "ARROW:extension:name", "value": "uuid"},
{"key": "ARROW:extension:metadata", "value": "uuid-serialized"}
{"key": "ARROW:extension:metadata", "value": ""}
]
}

Expand Down

0 comments on commit 3e324bc

Please sign in to comment.