Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions source/libs/executor/src/timewindowoperator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,10 +1112,12 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator,
}
}

// if the block ends with null state columns,
// we do not process them here,
// since we don't know the belonging of these null rows
if (pRowSup->numOfRows == 0) {
if (!pInfo->hasKey ||
(pRowSup->numOfRows == 0 &&
extendOption != STATE_WIN_EXTEND_OPTION_BACKWARD)) {
// if no valid state window or we don't know
// the belonging of these null rows,
// just return
return;
}
doKeepCurStateWindowEndInfo(pRowSup, tsList, *endIndex, &extendOption, false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"thread_count": 4,
"create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"num_of_records_per_req": 10000,
"prepared_rand": 10000,
"chinese": "no",
"escape_character": "yes",
"continue_if_fail": "no",
"databases": [
{
"dbinfo": {
"name": "test_end_null",
"drop": "false",
"vgroups": 2,
"precision": "ms",
"keep": 3650
},
"super_tables": [
{
"name": "test_stb",
"child_table_exists": "no",
"childtable_count": 1,
"childtable_prefix": "d",
"auto_create_table": "no",
"batch_create_tbl_num": 5,
"data_source": "rand",
"insert_mode": "taosc",
"non_stop_mode": "no",
"line_protocol": "line",
"insert_rows": 5000,
"childtable_limit": 0,
"childtable_offset": 0,
"interlace_rows": 0,
"insert_interval": 0,
"partial_col_num": 0,
"timestamp_step": 1000,
"start_timestamp": "2025-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"use_sample_ts": "no",
"tags_file": "",
"columns": [
{ "type": "INT", "name": "v", "len": 0 }
],
"tags": [
{"type": "TINYINT", "name": "groupid", "max": 10, "min": 1},
{"type": "BINARY", "name": "location", "len": 16,
"values": ["San Francisco", "Los Angles", "San Diego",
"San Jose", "Palo Alto", "Campbell", "Mountain View",
"Sunnyvale", "Santa Clara", "Cupertino"]
}
]
}
]
}
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# -*- coding: utf-8 -*-

import os
from new_test_framework.utils import tdSql, tdLog, tdCom, tdStream
from new_test_framework.utils import etool

Expand Down Expand Up @@ -45,6 +46,7 @@ def test_state_window_null_block(self):

"""
self.prepare_data()
self.check_end_with_null_block()
self.check_all_non_null()
self.check_inner_null()
self.check_border_null1()
Expand Down Expand Up @@ -77,6 +79,14 @@ def prepare_data(self):
datafile = etool.getFilePath(__file__, "data", "data6.csv")
tdSql.execute(f"insert into t6 file '{datafile}'")

# prepare with taosBenchmark
# insert 5k rows with all nulls
json_file = os.path.join(os.path.dirname(__file__), "json/all_null_5k.json")
etool.benchMark(json=json_file)
# insert to create a window
tdSql.execute("use test_end_null")
tdSql.execute("insert into d0 values('2025-10-01 01:00:00', 1);")

# test data pattern:
# | true ... true | true ... false | true ... true |
def check_all_non_null(self):
Expand Down Expand Up @@ -544,3 +554,24 @@ def check_all_null_block2(self):
tdSql.checkData(2, 2, True)
tdSql.checkData(2, 3, 5995)
tdSql.checkData(2, 4, 3995)

def check_end_with_null_block(self):
tdSql.execute("use test_end_null")
tdSql.query("select _wstart, _wend, count(*), sum(v) from d0 state_window(v)", show=True)
tdSql.checkRows(1)
tdSql.checkData(0, 0, "2025-10-01 01:00:00.000")
tdSql.checkData(0, 1, "2025-10-01 01:00:00.000")
tdSql.checkData(0, 2, 1)
tdSql.checkData(0, 3, 1)
tdSql.query("select _wstart, _wend, count(*), sum(v) from d0 state_window(v, 1)", show=True)
tdSql.checkRows(1)
tdSql.checkData(0, 0, "2025-10-01 01:00:00.000")
tdSql.checkData(0, 1, "2025-10-01 01:23:19.000")
tdSql.checkData(0, 2, 1400)
tdSql.checkData(0, 3, 1)
tdSql.query("select _wstart, _wend, count(*), sum(v) from d0 state_window(v, 2)", show=True)
tdSql.checkRows(1)
tdSql.checkData(0, 0, "2025-10-01 00:00:00.000")
tdSql.checkData(0, 1, "2025-10-01 01:00:00.000")
tdSql.checkData(0, 2, 3601)
tdSql.checkData(0, 3, 1)
Loading