Skip to content

Commit 79e2ee0

Browse files
committed
py: ensure aggtst_base returns an empty list for tables/views without input
Signed-off-by: rivudhk <rivudhkr@gmail.com>
1 parent bbcbc27 commit 79e2ee0

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

python/tests/runtime_aggtest/aggtst_base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ def run_pipeline(self, pipeline_name_prefix: str, sql: str, views: list[View]):
235235
pipeline.start()
236236

237237
for table in self.tables:
238-
pipeline.input_json(
239-
table.name, table.get_data(), update_format="insert_delete"
240-
)
238+
if table.get_data() != []:
239+
pipeline.input_json(
240+
table.name, table.get_data(), update_format="insert_delete"
241+
)
241242

242243
pipeline.wait_for_completion(force_stop=False, timeout_s=320)
243244

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Add here import statements for all files with tests
2+
3+
from tests.runtime_aggtest.aggtst_base import * # noqa: F403
4+
from tests.runtime_aggtest.atest_run import run # noqa: F403
5+
from test_lateness_check import * # noqa: F403
6+
7+
8+
def main():
9+
run("lateness_tests", "lateness_")
10+
11+
12+
if __name__ == "__main__":
13+
main()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from tests.runtime_aggtest.aggtst_base import TstView, TstTable
2+
3+
4+
# The following LATENESS test verifies that the feature works as expected,
5+
# And also that the tables/views with no data provided do not produce JSON NULL errors.
6+
class lateness_lateness_tbl(TstTable):
7+
"""Define the table used by the lateness tests"""
8+
9+
def __init__(self):
10+
self.sql = """CREATE TABLE purchase (
11+
ts TIMESTAMP NOT NULL LATENESS INTERVAL 1 HOUR,
12+
amount BIGINT
13+
) WITH (
14+
'append_only' = 'true'
15+
)"""
16+
self.data = []
17+
18+
19+
class lateness_lateness_check(TstView):
20+
def __init__(self):
21+
self.sql = """CREATE MATERIALIZED VIEW daily_total_final
22+
WITH ('emit_final' = 'd')
23+
AS
24+
SELECT
25+
TIMESTAMP_TRUNC(ts, DAY) AS d,
26+
SUM(amount) AS total
27+
FROM purchase
28+
GROUP BY TIMESTAMP_TRUNC(ts, DAY)"""

0 commit comments

Comments
 (0)