Skip to content

Commit df11948

Browse files
committed
Add test for coalescing null values with time window aggregation
1 parent 79c22d6 commit df11948

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test-coalesce-null.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from pyarrow import flight
2+
from datafusion import SessionContext
3+
4+
ctx = SessionContext()
5+
6+
test_data = [
7+
{
8+
"id": 1,
9+
"created_at": "2024-09-07 10:01:05",
10+
"content": "First entry in first minute",
11+
},
12+
{
13+
"id": 2,
14+
"created_at": "2024-09-07 10:01:45",
15+
"content": "Second entry in first minute",
16+
},
17+
{
18+
"id": 3,
19+
"created_at": "2024-09-07 10:03:10",
20+
"content": "First entry in third minute",
21+
},
22+
{
23+
"id": 4,
24+
"created_at": "2024-09-07 10:03:55",
25+
"content": "Second entry in third minute",
26+
},
27+
]
28+
29+
ctx.from_pylist(test_data, "count_me")
30+
31+
sql = """ SELECT
32+
DATE_BIN(INTERVAL '1 minute', created_at) AS time_window,
33+
COUNT(*) AS count
34+
FROM
35+
count_me
36+
37+
GROUP BY
38+
time_window
39+
ORDER BY
40+
time_window;"""
41+
42+
df = ctx.sql(sql)
43+
df.to_arrow_table()

0 commit comments

Comments
 (0)