-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEV-2320] added capability to specify window in str for aggregate (#325
) * added capability to specify window in str for aggregate * ran black * lint check * lint check * removed Window function from documentation --------- Co-authored-by: Nitin Bansal <[email protected]>
- Loading branch information
1 parent
6c9633e
commit 394b588
Showing
10 changed files
with
92 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2580,3 +2580,58 @@ def pipeline2(cls, a: Dataset, b: Dataset): | |
sync_request = view._get_sync_request_proto(tier="prod") | ||
pipelines = sync_request.pipelines | ||
assert len(pipelines) == 1 | ||
|
||
|
||
def test_dataset_with_str_window_aggregate(): | ||
@meta(owner="[email protected]") | ||
@dataset | ||
class UserAggregatesDataset: | ||
gender: str = field(key=True) | ||
timestamp: datetime = field(timestamp=True) | ||
count: int | ||
avg_age: float | ||
|
||
@pipeline(version=1) | ||
@inputs(UserInfoDataset) | ||
def create_aggregated_dataset(cls, user_info: Dataset): | ||
return user_info.groupby("gender").aggregate( | ||
Count(window="forever", into_field="count"), | ||
Average(of="age", window="forever", into_field="avg_age"), | ||
) | ||
|
||
view = InternalTestClient() | ||
view.add(UserAggregatesDataset) | ||
sync_request = view._get_sync_request_proto() | ||
assert len(sync_request.datasets) == 1 | ||
d = { | ||
"name": "UserAggregatesDataset", | ||
"metadata": {"owner": "[email protected]"}, | ||
"dsschema": { | ||
"keys": { | ||
"fields": [{"name": "gender", "dtype": {"stringType": {}}}] | ||
}, | ||
"values": { | ||
"fields": [ | ||
{"name": "count", "dtype": {"intType": {}}}, | ||
{"name": "avg_age", "dtype": {"doubleType": {}}}, | ||
] | ||
}, | ||
"timestamp": "timestamp", | ||
}, | ||
"history": "63072000s", | ||
"retention": "63072000s", | ||
"fieldMetadata": { | ||
"avg_age": {}, | ||
"count": {}, | ||
"gender": {}, | ||
"timestamp": {}, | ||
}, | ||
"pycode": {}, | ||
} | ||
# Ignoring schema validation since they are bytes and not human readable | ||
dataset_req = sync_request.datasets[0] | ||
dataset_req.pycode.Clear() | ||
expected_dataset_request = ParseDict(d, ds_proto.CoreDataset()) | ||
assert dataset_req == expected_dataset_request, error_message( | ||
dataset_req, expected_dataset_request | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters