diff --git a/cpp/gdb_arrow.py b/cpp/gdb_arrow.py index c3f5ab62981..b382d6d0022 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([('LIST_VIEW', 41), ('LARGE_LIST_VIEW', 42)]) + # 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'], @@ -1046,6 +1049,8 @@ def num_rows(self): 'FixedSizeBinaryType': 'fixed_size_binary', 'ListType': 'list', 'LargeListType': 'large_list', + 'ListViewType': 'list_view', + 'LargeListViewType': 'large_list_view', 'FixedSizeListType': 'fixed_size_list', 'MapType': 'map', 'StructType': 'struct_', @@ -2064,6 +2069,8 @@ class ExtensionTypeClass(DataTypeClass): Type.LIST: DataTypeTraits(BaseListTypeClass, 'ListType'), Type.LARGE_LIST: DataTypeTraits(BaseListTypeClass, 'LargeListType'), + Type.LIST_VIEW: DataTypeTraits(BaseListTypeClass, 'ListViewType'), + Type.LARGE_LIST_VIEW: DataTypeTraits(BaseListTypeClass, 'LargeListViewType'), Type.FIXED_SIZE_LIST: DataTypeTraits(FixedSizeListTypeClass, 'FixedSizeListType'), Type.MAP: DataTypeTraits(MapTypeClass, 'MapType'), diff --git a/python/pyarrow/src/arrow/python/gdb.cc b/python/pyarrow/src/arrow/python/gdb.cc index 2a7d2eda4bf..42bd08f83ff 100644 --- a/python/pyarrow/src/arrow/python/gdb.cc +++ b/python/pyarrow/src/arrow/python/gdb.cc @@ -174,8 +174,12 @@ void TestSession() { ListType list_type(uint8()); LargeListType large_list_type(large_utf8()); + ListViewType list_view_type(uint8()); + LargeListViewType large_list_view_type(large_utf8()); auto heap_list_type = list(uint8()); auto heap_large_list_type = large_list(large_utf8()); + auto heap_list_view_type = list_view(uint8()); + auto heap_large_list_view_type = large_list_view(large_utf8()); FixedSizeListType fixed_size_list_type(float64(), 3); auto heap_fixed_size_list_type = fixed_size_list(float64(), 3); @@ -332,6 +336,12 @@ void TestSession() { LargeListScalar large_list_scalar{list_value_array}; LargeListScalar large_list_scalar_null{list_zero_length, large_list(int32()), /*is_valid=*/false}; + ListViewScalar list_view_scalar{list_value_array}; + ListViewScalar list_view_scalar_null{list_zero_length, list_view(int32()), + /*is_valid=*/false}; + LargeListViewScalar large_list_view_scalar{list_value_array}; + LargeListViewScalar large_list_view_scalar_null{ + list_zero_length, large_list_view(int32()), /*is_valid=*/false}; FixedSizeListScalar fixed_size_list_scalar{list_value_array}; FixedSizeListScalar fixed_size_list_scalar_null{ list_value_array, fixed_size_list(int32(), 3), /*is_valid=*/false}; @@ -394,6 +404,11 @@ void TestSession() { auto heap_list_array = SliceArrayFromJSON(list(int64()), "[[1, 2], null, []]"); ListArray list_array{heap_list_array->data()}; + auto heap_list_view_array = + SliceArrayFromJSON(list_view(int64()), "[[1, 2], null, []]"); + ListViewArray list_view_array{heap_list_view_array->data()}; + auto heap_large_list_view_array = + SliceArrayFromJSON(large_list_view(int64()), "[[1, 2], null, []]"); const char* json_double_array = "[-1.5, null]"; auto heap_double_array = SliceArrayFromJSON(float64(), json_double_array); diff --git a/python/pyarrow/tests/test_gdb.py b/python/pyarrow/tests/test_gdb.py index 912953ae60d..99b8b16b626 100644 --- a/python/pyarrow/tests/test_gdb.py +++ b/python/pyarrow/tests/test_gdb.py @@ -375,6 +375,10 @@ def test_types_stack(gdb_arrow): "arrow::list(arrow::uint8())") check_stack_repr(gdb_arrow, "large_list_type", "arrow::large_list(arrow::large_utf8())") + check_stack_repr(gdb_arrow, "list_view_type", + "arrow::list_view(arrow::uint8())") + check_stack_repr(gdb_arrow, "large_list_view_type", + "arrow::large_list_view(arrow::large_utf8())") check_stack_repr(gdb_arrow, "fixed_size_list_type", "arrow::fixed_size_list(arrow::float64(), 3)") check_stack_repr( @@ -432,6 +436,10 @@ def test_types_heap(gdb_arrow): "arrow::list(arrow::uint8())") check_heap_repr(gdb_arrow, "heap_large_list_type", "arrow::large_list(arrow::large_utf8())") + check_heap_repr(gdb_arrow, "heap_list_view_type", + "arrow::list_view(arrow::uint8())") + check_heap_repr(gdb_arrow, "heap_large_list_view_type", + "arrow::large_list_view(arrow::large_utf8())") check_heap_repr(gdb_arrow, "heap_fixed_size_list_type", "arrow::fixed_size_list(arrow::float64(), 3)") check_heap_repr( @@ -680,6 +688,22 @@ def test_scalars_stack(gdb_arrow): gdb_arrow, "large_list_scalar_null", ('arrow::LargeListScalar of type arrow::large_list(arrow::int32()), ' 'null value')) + check_stack_repr( + gdb_arrow, "list_view_scalar", + ('arrow::ListViewScalar of value arrow::Int32Array of ' + 'length 3, offset 0, null count 0 = {[0] = 4, [1] = 5, [2] = 6}')) + check_stack_repr( + gdb_arrow, "list_view_scalar_null", + ('arrow::ListViewScalar of type arrow::list_view(arrow::int32()), ' + 'null value')) + check_stack_repr( + gdb_arrow, "large_list_view_scalar", + ('arrow::LargeListViewScalar of value arrow::Int32Array of ' + 'length 3, offset 0, null count 0 = {[0] = 4, [1] = 5, [2] = 6}')) + check_stack_repr( + gdb_arrow, "large_list_view_scalar_null", + ('arrow::LargeListViewScalar of type ' + 'arrow::large_list_view(arrow::int32()), null value')) check_stack_repr( gdb_arrow, "fixed_size_list_scalar", ('arrow::FixedSizeListScalar of value arrow::Int32Array of ' @@ -765,6 +789,10 @@ def test_arrays_stack(gdb_arrow): gdb_arrow, "list_array", ("arrow::ListArray of type arrow::list(arrow::int64()), " "length 3, offset 0, null count 1")) + check_stack_repr( + gdb_arrow, "list_view_array", + ("arrow::ListViewArray of type arrow::list_view(arrow::int64()), " + "length 3, offset 0, null count 1")) def test_arrays_heap(gdb_arrow): @@ -1002,6 +1030,14 @@ def test_arrays_heap(gdb_arrow): gdb_arrow, "heap_list_array", ("arrow::ListArray of type arrow::list(arrow::int64()), " "length 3, offset 0, null count 1")) + check_heap_repr( + gdb_arrow, "heap_list_view_array", + ("arrow::ListViewArray of type arrow::list_view(arrow::int64()), " + "length 3, offset 0, null count 1")) + check_heap_repr( + gdb_arrow, "heap_large_list_view_array", + ("arrow::LargeListViewArray of type arrow::large_list_view(arrow::int64()), " + "length 3, offset 0, null count 1")) def test_schema(gdb_arrow):