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

feat: allow callables in more places #714

Merged
merged 9 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
221 changes: 130 additions & 91 deletions python/pysrc/kaskada/_timestream.py

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions python/pytests/golden/ceil_test/test_ceil_unwindowed.jsonl

This file was deleted.

6 changes: 0 additions & 6 deletions python/pytests/golden/clamp_test/test_clamp.jsonl

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"_time":"1996-12-19T16:39:57.000000000","_key":"A","add":15.0,"time":"1996-12-19T16:39:57.000000000","key":"A","m":5.0,"n":10.0}
{"_time":"1996-12-19T16:39:58.000000000","_key":"B","add":27.0,"time":"1996-12-19T16:39:58.000000000","key":"B","m":24.0,"n":3.0}
{"_time":"1996-12-19T16:39:59.000000000","_key":"A","add":23.0,"time":"1996-12-19T16:39:59.000000000","key":"A","m":17.0,"n":6.0}
{"_time":"1996-12-19T16:40:00.000000000","_key":"A","add":null,"time":"1996-12-19T16:40:00.000000000","key":"A","m":null,"n":9.0}
{"_time":"1996-12-19T16:40:01.000000000","_key":"A","add":null,"time":"1996-12-19T16:40:01.000000000","key":"A","m":12.0,"n":null}
{"_time":"1996-12-19T16:40:02.000000000","_key":"A","add":null,"time":"1996-12-19T16:40:02.000000000","key":"A","m":null,"n":null}
6 changes: 6 additions & 0 deletions python/pytests/golden/record_test/test_extend_dict.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"_time":"1996-12-19T16:39:57.000000000","_key":"A","add":15.0,"time":"1996-12-19T16:39:57.000000000","key":"A","m":5.0,"n":10.0}
{"_time":"1996-12-19T16:39:58.000000000","_key":"B","add":27.0,"time":"1996-12-19T16:39:58.000000000","key":"B","m":24.0,"n":3.0}
{"_time":"1996-12-19T16:39:59.000000000","_key":"A","add":23.0,"time":"1996-12-19T16:39:59.000000000","key":"A","m":17.0,"n":6.0}
{"_time":"1996-12-19T16:40:00.000000000","_key":"A","add":null,"time":"1996-12-19T16:40:00.000000000","key":"A","m":null,"n":9.0}
{"_time":"1996-12-19T16:40:01.000000000","_key":"A","add":null,"time":"1996-12-19T16:40:01.000000000","key":"A","m":12.0,"n":null}
{"_time":"1996-12-19T16:40:02.000000000","_key":"A","add":null,"time":"1996-12-19T16:40:02.000000000","key":"A","m":null,"n":null}
6 changes: 0 additions & 6 deletions python/pytests/golden/time_of_test/test_time_of.jsonl

This file was deleted.

14 changes: 12 additions & 2 deletions python/pytests/record_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@ def test_record(source, golden) -> None:
)


def test_extend_record(source, golden) -> None:
def test_extend_dict(source, golden) -> None:
m = source.col("m")
n = source.col("n")
golden.jsonl(source.extend({"add": m + n}))


def test_extend_input(source, golden) -> None:
def test_extend_record(source, golden) -> None:
m = source.col("m")
n = source.col("n")
golden.jsonl(source.extend(kd.record({"add": m + n})))


def test_extend_computed_record(source, golden) -> None:
golden.jsonl(source.extend(lambda i: kd.record({"add": i.col("m") + i.col("n")})))


def test_extend_computed_dict(source, golden) -> None:
golden.jsonl(source.extend(lambda input: {"add": input.col("m") + input.col("n")}))


Expand Down
5 changes: 5 additions & 0 deletions python/pytests/timestream_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@ def test_timestream_cast(golden) -> None:
)
source = kd.sources.CsvString(content, time_column="time", key_column="key")
golden.jsonl(source.col("time").cast(pa.timestamp("ns")))


def test_timestream_call_all_literals() -> None:
with pytest.raises(ValueError, match="at least one non-literal"):
kd.Timestream._call("foo", 1, 2, 3)
Loading