Skip to content

Commit 1c346c2

Browse files
committed
[Python] Add test checking that the nowstream advances by itself
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
1 parent 1439372 commit 1c346c2

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import unittest
2+
import time
3+
4+
from feldera.pipeline_builder import PipelineBuilder
5+
from feldera.runtime_config import RuntimeConfig
6+
from feldera.testutils import unique_pipeline_name
7+
from tests import TEST_CLIENT
8+
from feldera.enums import PipelineStatus
9+
10+
def get_result(pipeline) -> str:
11+
result = list(pipeline.query("SELECT * FROM v;"))
12+
assert len(result) == 1
13+
return result[0]['x']
14+
15+
class TestNowStream(unittest.TestCase):
16+
def test_nowstream(self):
17+
"""
18+
Test the now() function:
19+
pipeline should produce outputs even if no new inputs are supplied.
20+
"""
21+
22+
pipeline_name = unique_pipeline_name("test_now")
23+
24+
sql = """
25+
CREATE MATERIALIZED VIEW v AS SELECT NOW() as X;
26+
"""
27+
28+
pipeline = PipelineBuilder(
29+
TEST_CLIENT,
30+
pipeline_name,
31+
sql=sql,
32+
runtime_config=RuntimeConfig(
33+
# 10 times per second
34+
clock_resolution_usecs=100000
35+
),
36+
).create_or_replace()
37+
38+
pipeline.start()
39+
assert pipeline.status() == PipelineStatus.RUNNING
40+
time0 = get_result(pipeline)
41+
time.sleep(1)
42+
time1 = get_result(pipeline)
43+
# Time has increased; this works on string time representations too
44+
# due to the standard format, which looks like `2025-10-20T20:55:16.350`
45+
assert time1 > time0
46+
pipeline.stop(force=True)
47+
48+
if __name__ == "__main__":
49+
unittest.main()

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/CompilerOptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ public static class IO implements IDiff<IO>, IValidate {
195195
@Parameter(names = "--jdbcSource",
196196
description = "Connection string to a database that contains table metadata")
197197
public String metadataSource = "";
198+
// This option is ignored; it is here just for backward compatibility, and it will be removed.
199+
@Parameter(names = "--nowstream", hidden = true,
200+
description = "Implement NOW as a stream (true) or as an internal operator (false)")
201+
public boolean ignored = true;
198202
@Parameter(names = "--sqlnames", hidden = true,
199203
description = "Use the table names as identifiers in the generated code")
200204
public boolean sqlNames = false;

0 commit comments

Comments
 (0)