Skip to content

Commit a06147b

Browse files
committed
added test of else method using un-ordered columns
1 parent beb5dda commit a06147b

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

python/pytests/else_test.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,35 @@ def test_else_debug(record_source, golden) -> None:
6363
}
6464
)
6565
)
66+
67+
@pytest.fixture(scope="module")
68+
def record_source_slack() -> kd.sources.JsonlString:
69+
content = "\n".join(
70+
[
71+
"""{"text":"Thread 1","user":"UCZ4","time":1,"thread_ts":1,"key":"dev"}""",
72+
"""{"text":"Thread 2","user":"U016","time":2,"thread_ts":1,"key":"dev"}""",
73+
"""{"text":"Msg 1","user":"U016","time":3,"thread_ts":null,"key":"dev"}""",
74+
"""{"text":"Msg 2","user":"U016","time":4,"thread_ts":null,"key":"dev"}""",
75+
]
76+
)
77+
return kd.sources.JsonlString(
78+
content, time_column_name="time", key_column_name="key"
79+
)
80+
81+
82+
def test_else_unordered_record(record_source_slack, golden) -> None:
83+
threads = record_source_slack.filter(record_source_slack.col("thread_ts").is_not_null())
84+
non_threads = record_source_slack.filter(record_source_slack.col("thread_ts").is_null())
85+
86+
# this call re-orders the columns in the non_threads timestream
87+
# and causes the bug to occur
88+
non_threads = non_threads.extend({"user": non_threads.col("user")})
89+
90+
joined = kd.record({"threads": threads, "non_threads": non_threads})
91+
92+
threads = joined.col("threads")
93+
non_threads = joined.col("non_threads")
94+
95+
golden.jsonl(
96+
joined.extend({"joined": threads.else_(non_threads)})
97+
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{"_time":"1970-01-01T00:00:00.000000001","_subsort":0,"_key_hash":17095134351192101601,"_key":"dev","joined":{"text":"Thread 1","user":"UCZ4","time":1,"thread_ts":1.0,"key":"dev"},"threads":{"text":"Thread 1","user":"UCZ4","time":1.0,"thread_ts":1.0,"key":"dev"},"non_threads":null}
2+
{"_time":"1970-01-01T00:00:00.000000002","_subsort":1,"_key_hash":17095134351192101601,"_key":"dev","joined":{"text":"Thread 2","user":"U016","time":2,"thread_ts":1.0,"key":"dev"},"threads":{"text":"Thread 2","user":"U016","time":2.0,"thread_ts":1.0,"key":"dev"},"non_threads":null}
3+
{"_time":"1970-01-01T00:00:00.000000003","_subsort":2,"_key_hash":17095134351192101601,"_key":"dev","joined":{"text":"Msg 1","user":"U016","time":3,"thread_ts":null,"key":"dev"},"threads":null,"non_threads":{"text":"Msg 1","user":"U016","time":3.0,"thread_ts":null,"key":"dev"}}
4+
{"_time":"1970-01-01T00:00:00.000000004","_subsort":3,"_key_hash":17095134351192101601,"_key":"dev","joined":{"text":"Msg 2","user":"U016","time":4,"thread_ts":null,"key":"dev"},"threads":null,"non_threads":{"text":"Msg 2","user":"U016","time":4.0,"thread_ts":null,"key":"dev"}}

0 commit comments

Comments
 (0)