Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix where ts < now used in nested query report invalid timestamp #22564

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/libs/function/src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -3221,7 +3221,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.name = "now",
.type = FUNCTION_TYPE_NOW,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
.translateFunc = translateNowToday,
.getEnvFunc = NULL,
.initFunc = NULL,
Expand All @@ -3231,7 +3231,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.name = "today",
.type = FUNCTION_TYPE_TODAY,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
.translateFunc = translateNowToday,
.getEnvFunc = NULL,
.initFunc = NULL,
Expand Down
12 changes: 12 additions & 0 deletions tests/system-test/2-query/Now.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ def run(self): # sourcery skip: extract-duplicate-method
self.now_check_ntb()
self.now_check_stb()

## TD-25540
tdSql.execute(f'create database db1')
tdSql.execute(f'use db1')
tdSql.execute(f"create table db1.tb (ts timestamp, c0 int)")
tdSql.execute(f'insert into db1.tb values(now + 1h, 1)')

for func in {"NOW", "NOW()", "TODAY()", "1", "'1970-01-01 00:00:00'"}:
tdSql.query(f"SELECT _wstart, count(*) FROM (SELECT ts, LAST(c0) FROM db1.tb WHERE ts > {func}) interval(1d);")
tdSql.checkRows(1)



def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
Expand Down