From 62508323b44330d88dec0ef8aa8658d84d4bd030 Mon Sep 17 00:00:00 2001 From: bitcapybara Date: Wed, 3 Jul 2024 07:52:28 +0000 Subject: [PATCH 1/2] test: [TS-5103] add test case for window fill value query --- tests/army/query/window/fill_value.py | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/army/query/window/fill_value.py diff --git a/tests/army/query/window/fill_value.py b/tests/army/query/window/fill_value.py new file mode 100644 index 0000000000..e3157f1295 --- /dev/null +++ b/tests/army/query/window/fill_value.py @@ -0,0 +1,55 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time + +import taos +from frame.log import * +from frame.cases import * +from frame.sql import * + +class TDTestCase: + # init + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + + # run + def run(self): + # init dtabase, table, data + tdSql.execute("create database test_db;") + tdSql.execute("create table test_db.test_tb (ts timestamp, k int);") + tdSql.execute("insert into test_db.test_tb values \ + ('2024-05-03 00:00:00.000', 2) \ + ('2024-06-03 00:00:00.000', 3);") + # query and check + tdSql.queryAndCheckResult([""" + select _wstart, _wend, ts, max(k) + from test_db.test_tb + where ts between '2024-05-03 00:00:00.000' and '2024-06-03 00:00:00.000' + interval(1h) fill(value, 0, 0) limit 2;"""], + [[ + ['2024-05-03 00:00:00.000', '2024-05-03 01:00:00.000', '2024-05-03 00:00:00.000', 2], + ['2024-05-03 01:00:00.000', '2024-05-03 02:00:00.000', '1970-01-01 00:00:00.000', 0], # fill `ts` with 0 + ]] + ) + # stop + def stop(self): + tdSql.execute("drop database test_db;") + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) From f4a83bfab79af329d55aa56f3857bb3363428c4d Mon Sep 17 00:00:00 2001 From: bitcapybara Date: Wed, 3 Jul 2024 08:17:33 +0000 Subject: [PATCH 2/2] test: add non-zero fill value in window query --- tests/army/query/window/fill_value.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/army/query/window/fill_value.py b/tests/army/query/window/fill_value.py index e3157f1295..a12ad6fe61 100644 --- a/tests/army/query/window/fill_value.py +++ b/tests/army/query/window/fill_value.py @@ -45,6 +45,16 @@ class TDTestCase: ['2024-05-03 01:00:00.000', '2024-05-03 02:00:00.000', '1970-01-01 00:00:00.000', 0], # fill `ts` with 0 ]] ) + tdSql.queryAndCheckResult([""" + select _wstart, _wend, ts, max(k) + from test_db.test_tb + where ts between '2024-05-03 00:00:00.000' and '2024-06-03 00:00:00.000' + interval(1h) fill(value, 1000, 10) limit 2;"""], + [[ + ['2024-05-03 00:00:00.000', '2024-05-03 01:00:00.000', '2024-05-03 00:00:00.000', 2], + ['2024-05-03 01:00:00.000', '2024-05-03 02:00:00.000', '1970-01-01 00:00:01.000', 10], # fill `ts` with 1000, `k` with 10 + ]] + ) # stop def stop(self): tdSql.execute("drop database test_db;")