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
40 changes: 33 additions & 7 deletions c_glib/arrow-glib/basic-data-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ G_BEGIN_DECLS
* #GArrowExtensionDataType is a base class for user-defined extension
* data types.
*
* #GArrowUnknownExtensionDataType is a class for unknown extension
* data types.
*
* #GArrowExtensionDataTypeRegistry is a class to manage extension
* data types.
*
Expand Down Expand Up @@ -2080,6 +2083,20 @@ namespace garrow {

G_BEGIN_DECLS

G_DEFINE_TYPE(GArrowUnknownExtensionDataType,
garrow_unknown_extension_data_type,
GARROW_TYPE_EXTENSION_DATA_TYPE)

static void
garrow_unknown_extension_data_type_init(GArrowUnknownExtensionDataType *object)
{
}

static void
garrow_unknown_extension_data_type_class_init(GArrowUnknownExtensionDataTypeClass *klass)
{
}
Comment on lines +2086 to +2098

typedef struct GArrowExtensionDataTypeRegistryPrivate_
{
std::shared_ptr<arrow::ExtensionTypeRegistry> registry;
Expand Down Expand Up @@ -2720,16 +2737,25 @@ garrow_data_type_new_raw(std::shared_ptr<arrow::DataType> *arrow_data_type)
type = GARROW_TYPE_DURATION_DATA_TYPE;
break;
case arrow::Type::type::EXTENSION:
type = GARROW_TYPE_UNKNOWN_EXTENSION_DATA_TYPE;
{
auto g_extension_data_type =
std::static_pointer_cast<garrow::GExtensionType>(*arrow_data_type);
if (g_extension_data_type) {
auto garrow_data_type = g_extension_data_type->garrow_data_type();
g_object_ref(garrow_data_type);
return GARROW_DATA_TYPE(garrow_data_type);
auto arrow_extension_data_type =
std::static_pointer_cast<arrow::ExtensionType>(*arrow_data_type);
auto name = arrow_extension_data_type->extension_name();
if (name == "arrow.fixed_shape_tensor") {
type = GARROW_TYPE_FIXED_SHAPE_TENSOR_DATA_TYPE;
} else if (name == "arrow.uuid") {
type = GARROW_TYPE_UUID_DATA_TYPE;
} else {
Comment on lines 2739 to +2749
auto g_extension_data_type =
std::dynamic_pointer_cast<garrow::GExtensionType>(*arrow_data_type);
if (g_extension_data_type) {
auto garrow_data_type = g_extension_data_type->garrow_data_type();
g_object_ref(garrow_data_type);
return GARROW_DATA_TYPE(garrow_data_type);
}
}
Comment on lines 2739 to 2757
}
type = GARROW_TYPE_EXTENSION_DATA_TYPE;
break;
case arrow::Type::type::FIXED_SIZE_LIST:
type = GARROW_TYPE_FIXED_SIZE_LIST_DATA_TYPE;
Expand Down
13 changes: 13 additions & 0 deletions c_glib/arrow-glib/basic-data-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,19 @@ GArrowChunkedArray *
garrow_extension_data_type_wrap_chunked_array(GArrowExtensionDataType *data_type,
GArrowChunkedArray *storage);

#define GARROW_TYPE_UNKNOWN_EXTENSION_DATA_TYPE \
(garrow_unknown_extension_data_type_get_type())
GARROW_AVAILABLE_IN_25_0
G_DECLARE_DERIVABLE_TYPE(GArrowUnknownExtensionDataType,
garrow_unknown_extension_data_type,
GARROW,
UNKNOWN_EXTENSION_DATA_TYPE,
GArrowExtensionDataType)
struct _GArrowUnknownExtensionDataTypeClass
{
GArrowExtensionDataTypeClass parent_class;
};

#define GARROW_TYPE_EXTENSION_DATA_TYPE_REGISTRY \
(garrow_extension_data_type_registry_get_type())
GARROW_AVAILABLE_IN_3_0
Expand Down
5 changes: 5 additions & 0 deletions c_glib/test/test-fixed-shape-tensor-data-type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,9 @@ def test_mismatch_dim_names_size
assert_equal(message,
error.message.lines.first.chomp)
end

def test_converted_from_cpp
schema = Arrow::Schema.new([Arrow::Field.new("tensor", @data_type)])
assert_equal(@data_type, schema.fields[0].data_type)
end
end
5 changes: 5 additions & 0 deletions c_glib/test/test-uuid-data-type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ def test_name
def test_to_s
assert_equal("extension<arrow.uuid>", @data_type.to_s)
end

def test_converted_from_cpp
schema = Arrow::Schema.new([Arrow::Field.new("uuid", @data_type)])
assert_equal(@data_type, schema.fields[0].data_type)
end
end
Loading