Skip to content

Commit

Permalink
Merge pull request #22564 from taosdata/fix/TD-25540-new
Browse files Browse the repository at this point in the history
fix: fix where ts < now used in nested query report invalid timestamp
  • Loading branch information
dapan1121 committed Aug 30, 2023
2 parents d054c7f + b5172e8 commit a1c55d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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

0 comments on commit a1c55d0

Please sign in to comment.