Skip to content

Commit

Permalink
test: Verify pylist sources drop unneeded columns (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjchambers authored Aug 14, 2023
1 parent 9a9b793 commit 67e5a58
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"_time":"1996-12-19T16:39:57.000","_subsort":0,"_key_hash":12960666915911099378,"_key":"A","time":"1996-12-19T16:39:57","user":"A","n":10}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"_time":"1996-12-19T16:39:57.000","_subsort":0,"_key_hash":12960666915911099378,"_key":"A","time":"1996-12-19T16:39:57","user":"A","n":10.0}
{"_time":"1996-12-19T16:40:57.000","_subsort":1,"_key_hash":12960666915911099378,"_key":"A","time":"1996-12-19T16:40:57","user":"A","n":10.0}
{"_time":"1996-12-19T16:41:57.000","_subsort":2,"_key_hash":12960666915911099378,"_key":"A","time":"1996-12-19T16:41:57","user":"A","n":null}
17 changes: 17 additions & 0 deletions python/pytests/pylist_source_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,20 @@ def test_read_pylist_lists(golden) -> None:
]
)
golden.jsonl(source)

def test_read_pylist_ignore_column(golden) -> None:
# Schema is determined from first row, and doesn't contain an "m" column.
source = kd.sources.PyList(
[{"time": "1996-12-19T16:39:57", "user": "A", "n": 10}],
time_column_name="time",
key_column_name="user",
)
golden.jsonl(source)

source.add_rows(
[
{"time": "1996-12-19T16:40:57", "user": "A", "m": 83, "n": 10},
{"time": "1996-12-19T16:41:57", "user": "A", "m": 12},
]
)
golden.jsonl(source)

0 comments on commit 67e5a58

Please sign in to comment.