Merge pull request #22564 from taosdata/fix/TD-25540-new

fix: fix where ts < now used in nested query report invalid timestamp
This commit is contained in:
dapan1121 2023-08-30 16:48:20 +08:00 committed by GitHub
commit a1c55d0584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -3221,7 +3221,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{ {
.name = "now", .name = "now",
.type = FUNCTION_TYPE_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, .translateFunc = translateNowToday,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
@ -3231,7 +3231,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{ {
.name = "today", .name = "today",
.type = FUNCTION_TYPE_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, .translateFunc = translateNowToday,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,

View File

@ -101,6 +101,18 @@ class TDTestCase:
self.now_check_ntb() self.now_check_ntb()
self.now_check_stb() 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): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")