diff --git a/cpp/gdb_arrow.py b/cpp/gdb_arrow.py index c3f5ab62981..8872d34478c 100644 --- a/cpp/gdb_arrow.py +++ b/cpp/gdb_arrow.py @@ -47,8 +47,11 @@ 'EXTENSION', 'FIXED_SIZE_LIST', 'DURATION', 'LARGE_STRING', 'LARGE_BINARY', 'LARGE_LIST', 'INTERVAL_MONTH_DAY_NANO'] +_type_id_tuples = [(name, i) for i, name in enumerate(_type_ids)] +_type_id_tuples.extend([('STRING_VIEW', 39), ('BINARY_VIEW', 40)]) + # Mirror the C++ Type::type enum -Type = enum.IntEnum('Type', _type_ids, start=0) +Type = enum.IntEnum('Type', _type_id_tuples) # Mirror the C++ TimeUnit::type enum TimeUnit = enum.IntEnum('TimeUnit', ['SECOND', 'MILLI', 'MICRO', 'NANO'], @@ -1041,8 +1044,10 @@ def num_rows(self): 'Decimal256Type': 'decimal256', 'StringType': 'utf8', 'LargeStringType': 'large_utf8', + 'StringViewType': 'utf8_view', 'BinaryType': 'binary', 'LargeBinaryType': 'large_binary', + 'BinaryViewType': 'binary_view', 'FixedSizeBinaryType': 'fixed_size_binary', 'ListType': 'list', 'LargeListType': 'large_list', @@ -2042,6 +2047,8 @@ class ExtensionTypeClass(DataTypeClass): Type.BINARY: DataTypeTraits(BaseBinaryTypeClass, 'BinaryType'), Type.LARGE_STRING: DataTypeTraits(BaseBinaryTypeClass, 'LargeStringType'), Type.LARGE_BINARY: DataTypeTraits(BaseBinaryTypeClass, 'LargeBinaryType'), + Type.STRING_VIEW: DataTypeTraits(BaseBinaryTypeClass, 'StringViewType'), + Type.BINARY_VIEW: DataTypeTraits(BaseBinaryTypeClass, 'BinaryViewType'), Type.FIXED_SIZE_BINARY: DataTypeTraits(FixedSizeBinaryTypeClass, 'FixedSizeBinaryType'), diff --git a/python/pyarrow/src/arrow/python/gdb.cc b/python/pyarrow/src/arrow/python/gdb.cc index 2a7d2eda4bf..6ff6bfd9745 100644 --- a/python/pyarrow/src/arrow/python/gdb.cc +++ b/python/pyarrow/src/arrow/python/gdb.cc @@ -165,6 +165,10 @@ void TestSession() { StringType string_type; LargeBinaryType large_binary_type; LargeStringType large_string_type; + BinaryViewType binary_view_type; + StringViewType string_view_type; + auto heap_binary_view_type = binary_view(); + auto heap_string_view_type = utf8_view(); FixedSizeBinaryType fixed_size_binary_type(10); auto heap_fixed_size_binary_type = fixed_size_binary(10); @@ -313,6 +317,10 @@ void TestSession() { LargeBinaryScalar large_binary_scalar_abc{Buffer::FromString("abc")}; LargeStringScalar large_string_scalar_hehe{Buffer::FromString("héhé")}; + BinaryViewScalar binary_view_scalar_null{binary_view()}; + BinaryViewScalar binary_view_scalar_abc{Buffer::FromString("abc")}; + StringViewScalar string_view_scalar_null{utf8_view()}; + StringViewScalar string_view_scalar_hehe{Buffer::FromString("héhé")}; FixedSizeBinaryScalar fixed_size_binary_scalar{Buffer::FromString("abc"), fixed_size_binary(3)}; diff --git a/python/pyarrow/tests/test_gdb.py b/python/pyarrow/tests/test_gdb.py index 912953ae60d..133dd750487 100644 --- a/python/pyarrow/tests/test_gdb.py +++ b/python/pyarrow/tests/test_gdb.py @@ -368,6 +368,8 @@ def test_types_stack(gdb_arrow): check_stack_repr(gdb_arrow, "string_type", "arrow::utf8()") check_stack_repr(gdb_arrow, "large_binary_type", "arrow::large_binary()") check_stack_repr(gdb_arrow, "large_string_type", "arrow::large_utf8()") + check_stack_repr(gdb_arrow, "binary_view_type", "arrow::binary_view()") + check_stack_repr(gdb_arrow, "string_view_type", "arrow::utf8_view()") check_stack_repr(gdb_arrow, "fixed_size_binary_type", "arrow::fixed_size_binary(10)") @@ -427,6 +429,8 @@ def test_types_heap(gdb_arrow): check_heap_repr(gdb_arrow, "heap_decimal128_type", "arrow::decimal128(16, 5)") + check_heap_repr(gdb_arrow, "heap_binary_view_type", "arrow::binary_view()") + check_heap_repr(gdb_arrow, "heap_string_view_type", "arrow::utf8_view()") check_heap_repr(gdb_arrow, "heap_list_type", "arrow::list(arrow::uint8())") @@ -625,6 +629,12 @@ def test_scalars_stack(gdb_arrow): check_stack_repr( gdb_arrow, "large_binary_scalar_abc", 'arrow::LargeBinaryScalar of size 3, value "abc"') + check_stack_repr( + gdb_arrow, "binary_view_scalar_null", + "arrow::BinaryViewScalar of null value") + check_stack_repr( + gdb_arrow, "binary_view_scalar_abc", + 'arrow::BinaryViewScalar of size 3, value "abc"') check_stack_repr( gdb_arrow, "string_scalar_null", @@ -645,6 +655,12 @@ def test_scalars_stack(gdb_arrow): check_stack_repr( gdb_arrow, "large_string_scalar_hehe", 'arrow::LargeStringScalar of size 6, value "héhé"') + check_stack_repr( + gdb_arrow, "string_view_scalar_null", + "arrow::StringViewScalar of null value") + check_stack_repr( + gdb_arrow, "string_view_scalar_hehe", + 'arrow::StringViewScalar of size 6, value "héhé"') check_stack_repr( gdb_arrow, "fixed_size_binary_scalar",