Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for 'group_dy' without 'partition_by' #650

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Changes from 1 commit
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
42 changes: 42 additions & 0 deletions tests/unit/lib/test_datachain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,48 @@ def test_group_by_multiple_partition_by(test_session):
)


def test_group_by_no_partition_by(test_session):
from datachain import func

ds = (
DataChain.from_values(
col1=["a", "a", "b", "b", "b", "c"],
col2=[1, 2, 1, 2, 1, 2],
col3=[1.0, 2.0, 3.0, 4.0, 5.0, 6.0],
col4=["1", "2", "3", "4", "5", "6"],
session=test_session,
)
.group_by(
cnt=func.count(),
cnt_col=func.count("col2"),
sum=func.sum("col3"),
concat=func.concat("col4"),
value=func.any_value("col3"),
collect=func.collect("col3"),
)
.save("my-ds")
)

assert ds.signals_schema.serialize() == {
"cnt": "int",
"cnt_col": "int",
"sum": "float",
"concat": "str",
"value": "float",
"collect": "list[float]",
}
assert ds.to_records() == [
{
"cnt": 6,
"cnt_col": 6,
"sum": 21.0,
"concat": "123456",
"value": 1.0,
"collect": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0],
},
]


def test_group_by_error(test_session):
from datachain import func

Expand Down
Loading