-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the count aggregation to the new python implementation. Adds `count` in #662 .
- Loading branch information
1 parent
d3dba5d
commit fffc1ac
Showing
11 changed files
with
90 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import kaskada as kd | ||
|
||
|
||
def test_count_unwindowed(source, golden) -> None: | ||
m = source.col("m") | ||
n = source.col("n") | ||
golden.jsonl( | ||
kd.record({"m": m, "count_m": m.count(), "n": n, "count_n": n.count()}) | ||
) | ||
|
||
|
||
def test_count_windowed(source, golden) -> None: | ||
m = source.col("m") | ||
n = source.col("n") | ||
golden.jsonl( | ||
kd.record( | ||
{ | ||
"m": m, | ||
"count_m": m.count(window=kd.windows.Since(m > 20)), | ||
"n": n, | ||
"count_n": n.count(window=kd.windows.Sliding(2, m > 10)), | ||
} | ||
) | ||
) | ||
|
||
|
||
def test_count_since_true(source, golden) -> None: | ||
# `since(True)` should be the same as unwindowed, so equals to one whenever the value is non-null | ||
m_sum_since_true = kd.record( | ||
{ | ||
"m": source.col("m"), | ||
"m_count": source.col("m").count(window=kd.windows.Since(True)), | ||
} | ||
) | ||
golden.jsonl(m_sum_since_true) |
17 changes: 0 additions & 17 deletions
17
python/pytests/aggregation_test.py → python/pytests/aggregation/sum_test.py
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{"_time":"1996-12-19T16:39:57.000","_subsort":0,"_key_hash":12960666915911099378,"_key":"A","m":5.0,"m_count":1} | ||
{"_time":"1996-12-19T16:39:58.000","_subsort":1,"_key_hash":2867199309159137213,"_key":"B","m":24.0,"m_count":1} | ||
{"_time":"1996-12-19T16:39:59.000","_subsort":2,"_key_hash":12960666915911099378,"_key":"A","m":17.0,"m_count":1} | ||
{"_time":"1996-12-19T16:40:00.000","_subsort":3,"_key_hash":12960666915911099378,"_key":"A","m":null,"m_count":0} | ||
{"_time":"1996-12-19T16:40:01.000","_subsort":4,"_key_hash":12960666915911099378,"_key":"A","m":12.0,"m_count":1} | ||
{"_time":"1996-12-19T16:40:02.000","_subsort":5,"_key_hash":12960666915911099378,"_key":"A","m":null,"m_count":0} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{"_time":"1996-12-19T16:39:57.000","_subsort":0,"_key_hash":12960666915911099378,"_key":"A","m":5.0,"count_m":1,"n":10.0,"count_n":1} | ||
{"_time":"1996-12-19T16:39:58.000","_subsort":1,"_key_hash":2867199309159137213,"_key":"B","m":24.0,"count_m":1,"n":3.0,"count_n":1} | ||
{"_time":"1996-12-19T16:39:59.000","_subsort":2,"_key_hash":12960666915911099378,"_key":"A","m":17.0,"count_m":2,"n":6.0,"count_n":2} | ||
{"_time":"1996-12-19T16:40:00.000","_subsort":3,"_key_hash":12960666915911099378,"_key":"A","m":null,"count_m":2,"n":9.0,"count_n":3} | ||
{"_time":"1996-12-19T16:40:01.000","_subsort":4,"_key_hash":12960666915911099378,"_key":"A","m":12.0,"count_m":3,"n":null,"count_n":3} | ||
{"_time":"1996-12-19T16:40:02.000","_subsort":5,"_key_hash":12960666915911099378,"_key":"A","m":null,"count_m":3,"n":null,"count_n":3} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{"_time":"1996-12-19T16:39:57.000","_subsort":0,"_key_hash":12960666915911099378,"_key":"A","m":5.0,"count_m":1,"n":10.0,"count_n":1} | ||
{"_time":"1996-12-19T16:39:58.000","_subsort":1,"_key_hash":2867199309159137213,"_key":"B","m":24.0,"count_m":1,"n":3.0,"count_n":1} | ||
{"_time":"1996-12-19T16:39:59.000","_subsort":2,"_key_hash":12960666915911099378,"_key":"A","m":17.0,"count_m":2,"n":6.0,"count_n":2} | ||
{"_time":"1996-12-19T16:40:00.000","_subsort":3,"_key_hash":12960666915911099378,"_key":"A","m":null,"count_m":2,"n":9.0,"count_n":3} | ||
{"_time":"1996-12-19T16:40:01.000","_subsort":4,"_key_hash":12960666915911099378,"_key":"A","m":12.0,"count_m":3,"n":null,"count_n":3} | ||
{"_time":"1996-12-19T16:40:02.000","_subsort":5,"_key_hash":12960666915911099378,"_key":"A","m":null,"count_m":3,"n":null,"count_n":1} |
File renamed without changes.
File renamed without changes.
File renamed without changes.