Skip to content

Commit

Permalink
add nested
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka committed Oct 5, 2024
1 parent 0139a6b commit f3104c5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 23 additions & 0 deletions tests/expressions/test_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
import pytz

import daft
from daft.datatype import DataType, TimeUnit
from daft.expressions import col, lit
from daft.expressions.testing import expr_structurally_equal
Expand Down Expand Up @@ -535,3 +536,25 @@ def test_list_value_counts():
none_mp = MicroPartition.from_pydict({"list_col": [None, None, None]})
with pytest.raises(ValueError):
none_mp.eval_expression_list([col("list_col").list.value_counts().alias("value_counts")])

def test_list_value_counts_nested():
# Create a MicroPartition with a nested list column
mp = MicroPartition.from_pydict(
{
"nested_list_col": [
[[1, 2], [3, 4]],
[[1, 2], [5, 6]],
[[3, 4], [1, 2]],
[],
None,
[[1, 2], [1, 2]],
]
}
)

# Apply list_value_counts operation and expect an exception
with pytest.raises(daft.exceptions.DaftCoreException) as exc_info:
mp.eval_expression_list([col("nested_list_col").list.value_counts().alias("value_counts")])

# Check the exception message
assert "DaftError::ArrowError Invalid argument error: The data type type LargeList(Field { name: \"item\", data_type: Int64, is_nullable: true, metadata: {} }) has no natural order" in str(exc_info.value)
1 change: 0 additions & 1 deletion tests/table/map/test_map_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ def test_map_get_bad_field():
table.eval_expression_list([col("map_col").map.get("foo")])


test_map_get_logical_type()

0 comments on commit f3104c5

Please sign in to comment.