Skip to content

Commit

Permalink
Add test for large list
Browse files Browse the repository at this point in the history
  • Loading branch information
aandres3 committed Jan 14, 2025
1 parent ffc452e commit d2cbfbe
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

<!-- insertion marker -->
## [v0.10.0](https://github.com/tradewelltech/protarrow/releases/tag/v0.10.0) - 2025-01-14

<small>[Compare with v0.9.0](https://github.com/tradewelltech/protarrow/compare/v0.9.0...v0.10.0)</small>

### Added

- Add test for large list ([498f732](https://github.com/tradewelltech/protarrow/commit/498f7321ddfb40ce0ac7326781a7e98e278ffb72) by aandres3).
- Add check for both `pa.types.is_list` and `pa.types.is_large_list` in assertions (#88) ([ffc452e](https://github.com/tradewelltech/protarrow/commit/ffc452e81c6186048a6b93aaecc122c3c8ea98c8) by chase).

## [v0.9.0](https://github.com/tradewelltech/protarrow/releases/tag/v0.9.0) - 2024-12-27

<small>[Compare with v0.8.0](https://github.com/tradewelltech/protarrow/compare/v0.8.0...v0.9.0)</small>
Expand Down
56 changes: 55 additions & 1 deletion tests/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ def test_duration_specific():
assert messages_back == expected


def test_large_list_in_cast():
def test_large_list_primitive():
table = pa.table(
{
"double_values": pa.LargeListArray.from_arrays(
Expand All @@ -869,3 +869,57 @@ def test_large_list_in_cast():
}
)
assert isinstance(cast_table(table, ExampleMessage, ProtarrowConfig()), pa.Table)
protos = protarrow.table_to_messages(table, ExampleMessage)
assert protos == [
ExampleMessage(double_values=[1.1, 2.2, 3.3]),
ExampleMessage(),
ExampleMessage(double_values=[4.4, 5.5]),
]


def test_large_list_nested():
table = pa.table(
{"example_message": pa.array([{"double_value": 1.0}, {"double_value": 2.0}])}
)
assert isinstance(
cast_table(table, NestedExampleMessage, ProtarrowConfig()), pa.Table
)
protos = protarrow.table_to_messages(table, NestedExampleMessage)
assert protos == [
NestedExampleMessage(example_message=ExampleMessage(double_value=1.0)),
NestedExampleMessage(example_message=ExampleMessage(double_value=2.0)),
]


def test_large_list_nested_repeated():
table = pa.table(
{
"repeated_example_message": pa.LargeListArray.from_arrays(
offsets=[0, 2],
values=pa.array([{"double_value": 1.0}, {"double_value": 2.0}]),
)
}
)
assert isinstance(
cast_table(table, NestedExampleMessage, ProtarrowConfig()), pa.Table
)
protos = protarrow.table_to_messages(table, NestedExampleMessage)
assert protos == [
NestedExampleMessage(
repeated_example_message=[
ExampleMessage(double_value=1.0),
ExampleMessage(double_value=2.0),
]
)
]


def test_large_list_cast_nested():
table = pa.table(
{"repeated_nested_example_message": pa.nulls(10, pa.large_list(pa.struct([])))}
)
protarrow.cast_table(table, SuperNestedExampleMessage, protarrow.ProtarrowConfig())
assert (
protarrow.table_to_messages(table, SuperNestedExampleMessage)
== [SuperNestedExampleMessage()] * 10
)

0 comments on commit d2cbfbe

Please sign in to comment.