github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/window/time_window.sql (about) 1 drop database if exists time_window; 2 create database time_window; 3 use time_window; 4 5 -- abnormal test: the time column is not primary key column 6 drop table if exists time_window01; 7 create table time_window01 (ts timestamp, col2 int); 8 insert into time_window01 values ('2021-01-12 00:00:00.000', 12); 9 insert into time_window01 values ('2020-01-12 12:00:12.000', 24); 10 insert into time_window01 values ('2021-01-12 00:00:00.000', 34); 11 insert into time_window01 values ('2020-01-12 12:00:12.000', 20); 12 select * from time_window01; 13 select _wstart, _wend, max(col2), min(col2) from time_window01 where ts > '2020-01-11 12:00:12.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 100, day) fill(prev); 14 drop table time_window01; 15 16 drop table if exists time_window02; 17 create table time_window02 (ts timestamp primary key , col2 bool); 18 insert into time_window02 values ('2023-10-26 10:00:00.000', false); 19 insert into time_window02 values ('2023-10-26 10:10:00.000', true); 20 insert into time_window02 values ('2023-10-26 10:20:00.000', null); 21 insert into time_window02 values ('2023-10-26 10:30:00.000', true); 22 select * from time_window02; 23 select _wstart, _wend, max(col2), min(col2) from time_window02 where ts > '2020-01-11 12:00:12.000' and ts < '2024-01-13 00:00:00.000' interval(ts, 10, second) fill(prev); 24 drop table time_window02; 25 26 -- abnormal test: the primary key column of time window is not timestamp 27 drop table if exists time_window03; 28 create table time_window03 (ts datetime primary key , col2 int); 29 insert into time_window03 values ('2021-01-12 00:00:00', 12); 30 insert into time_window03 values ('2020-01-12 12:00:12', 24); 31 insert into time_window03 values ('2021-01-14 00:00:00', 34); 32 insert into time_window03 values ('2020-01-16 12:00:12', 20); 33 select * from time_window03; 34 select _wstart, _wend, max(col2), min(col2) from time_window03 where ts > '2020-01-11 12:00:12.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 100, day) fill(prev); 35 drop table time_window03; 36 37 -- abnormal test: the aggr column is char/varchar/text 38 drop table if exists time_window04; 39 create table time_window04 (ts timestamp primary key, col2 char, col3 varchar(10), col4 text); 40 insert into time_window04 values ('2023-10-26 10:00:00.000', 'a', 'b', 'djiweijwfcjwefwq'); 41 insert into time_window04 values ('2020-01-12 12:00:12.000', '1', '2', 'efwq3232e数据库系统'); 42 insert into time_window04 values ('2021-01-12 00:00:00.000', '是', 'srewrew', null); 43 insert into time_window04 values ('2023-10-26 10:30:00.000', 'w', null, null); 44 select * from time_window04; 45 select _wstart, _wend, max(col2), min(col3), max() from time_window04 where ts > '2020-01-11 12:00:12.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 100, day) fill(prev); 46 drop table time_window04; 47 48 -- abnormal test: the time column is date 49 drop table if exists time_window05; 50 create table time_window05 (ts datetime primary key , col2 decimal); 51 insert into time_window05 values ('2022-10-10', 4324.43423); 52 insert into time_window05 values ('2022-10-12', -4324.43423); 53 select * from time_window05; 54 select _wstart, _wend, max(col2) from time_window05 where ts > '2020-01-11 12:00:12.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 100, day) fill(prev); 55 drop table time_window05; 56 57 -- abnormal test:column ts is the type timestamp,but it is not primary key 58 drop table if exists time_window06; 59 create table time_window06 (ts timestamp, col2 int); 60 insert into time_window06 values ('2020-01-01 10:00:00.000', 212332); 61 insert into time_window06 values ('2020-01-02 12:00:00.000', -3890232); 62 insert into time_window06 values ('2020-01-04 09:00:00.000', null); 63 select * from time_window06; 64 select _wstart, _wend, max(col2) from time_window05 where ts > '2020-01-11 12:00:12.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 100, day) fill(prev); 65 drop table time_window06; 66 67 -- abnormal test:interval is less than 1s 68 drop table if exists time_window07; 69 create table time_window07 (ts timestamp primary key, col2 smallint unsigned); 70 insert into time_window07 values ('2020-01-01 10:00:00.000', 127); 71 insert into time_window07 values ('2020-01-02 12:00:00.000', 0); 72 select _wstart, _wend, max(col2) from time_window07 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 0.1, second) fill(next); 73 drop table time_window07; 74 75 -- abnormal test:sliding window is larger than time window 76 drop table if exists time_window08; 77 create table time_window08 (ts timestamp primary key, col2 smallint unsigned); 78 insert into time_window08 values ('2020-01-01 10:00:00.000', 127); 79 insert into time_window08 values ('2020-01-02 12:00:00.000', 0); 80 insert into time_window08 values ('2020-01-03 12:00:00.000', 22); 81 select _wstart, _wend, max(col2) from time_window08 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 1, day) sliding(2,day); 82 drop table time_window08; 83 84 -- the aggr column is int,with agg function max,min,avg,sum,count, interval day hour 85 drop table if exists int01; 86 create table int01 (ts timestamp primary key , col2 tinyint unsigned, col3 smallint, col4 bigint unsigned); 87 insert into int01 values ('2020-01-01 10:00:00.000', 127, null, 32151654354); 88 insert into int01 values ('2020-01-02 12:00:00.000', 0, null, 9223372036854775807); 89 insert into int01 values ('2020-01-03 13:00:00.000', 64, null, null); 90 insert into int01 values ('2020-01-04 09:00:00.000', 100, -1921, 32173892173092); 91 insert into int01 values ('2020-01-05 09:00:00.000', 200, 0, 37219739821); 92 insert into int01 values ('2020-01-06 09:00:00.000', 200, 0, 294095); 93 select * from int01; 94 select _wstart, _wend, max(col2), min(col3), avg(col4) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 1, day); 95 select _wstart, _wend, max(col2), min(col3), avg(col4) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 1, day) fill(prev); 96 select _wstart, _wend, max(col2), min(col3), avg(col4) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 1, day) fill(next); 97 select _wstart, _wend, max(col2), min(col3), avg(col4) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 1, day) fill(linear); 98 select _wstart, _wend, max(col2), min(col3), avg(col4) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 1, day) fill(none); 99 select _wstart, _wend, max(col2), min(col3), avg(col4) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 1, day) fill(VALUE,200); 100 select _wstart, _wend, max(col2), min(col3), avg(col4) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 24, hour); 101 select _wstart, _wend, sum(col2), sum(col3), sum(col4) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 13, hour); 102 select _wstart, _wend, sum(col2), sum(col3), sum(col4) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 2, day); 103 select _wstart, _wend, count(col2) from int01 where ts > '2020-01-01 00:00:00.000' and ts < '2021-01-13 00:00:00.000' interval(ts, 1, day) fill(none); 104 drop table int01; 105 106 -- the aggr column is decimal,float,double with agg function max,min,avg,sum,count,interval hour 107 drop table if exists int02; 108 create table int02 (ts timestamp primary key, col2 float, col3 double, col4 decimal(30,10)); 109 insert into int02 values ('2023-10-27 00:00:00.000', 321421.42314, 38021.324143214, 321798372091.324213421421342); 110 insert into int02 values ('2023-10-27 01:01:00.000', -2379823.0, 214214.32143214, -321798372091.324213421421342); 111 insert into int02 values ('2023-10-27 01:59:12.123', 321421.42314, null, 321798372091.324213421421342); 112 insert into int02 values ('2023-10-27 02:10:12.123', 321421.42314, -38021.111, null); 113 insert into int02 values ('2023-10-27 02:39:12.123', 0, 38021.324143214, 321798372091.324213421421342); 114 insert into int02 values ('2023-10-27 03:02:12.123', -321.42314832, 43824.43543, null); 115 insert into int02 values ('2023-10-27 12:10:12.110', 0, 0, 0); 116 insert into int02 values ('2023-10-27 12:33:12.110', 321421.42314, 2222, 3211.324213487734324535432523421421342); 117 insert into int02 values ('2023-10-27 13:33:12.110', 8430923, 332, 0); 118 insert into int02 values ('2023-10-27 13:33:15.110', 2141243.423141234213421421, 38021.324143214, 321798372091.324213421421342); 119 insert into int02 values ('2023-10-27 23:33:15.110', 321421.42314, 38021.324143214, 321798372091.324213421421342); 120 insert into int02 values ('2023-10-27 22:33:15.110', 321421.42314, null, null); 121 select * from int02; 122 select _wstart, _wend, max(col2), min(col3), min(col4) from int02 where ts >= '2023-10-27 00:00:00.000' and ts < '2023-10-27 23:00:00.000' interval(ts, 1, hour) fill(none); 123 select _wstart, _wend, max(col2), min(col3), min(col4) from int02 where ts > '2023-10-27 00:00:00.000' and ts < '2023-10-27 23:00:00.000' interval(ts, 10, minute) fill(next); 124 select _wstart, _wend, sum(col2), sum(col3), sum(col4) from int02 where ts > '2023-10-27 00:00:00.000' and ts < '2023-10-27 23:00:00.000' interval(ts, 60, minute) fill(next); 125 select _wstart, _wend, avg(col2), avg(col3), avg(col4) from int02 where ts > '2023-10-27 00:00:00.000' and ts < '2023-10-27 23:00:00.000' interval(ts, 20, minute); 126 select _wstart, _wend, count(col2), count(col3), count(col4) from int02 where ts > '2023-10-27 00:00:00.000' and ts < '2023-10-27 23:00:00.000' interval(ts, 30, minute) fill(prev); 127 drop table int02; 128 129 -- interval and sliding window with fill 130 drop table if exists sliding_window01; 131 create table sliding_window01 (ts timestamp(3) primary key , col2 double); 132 insert into sliding_window01 values ('2023-08-01 00:00:00', 25.0); 133 insert into sliding_window01 values ('2023-08-01 00:05:00', 26.0); 134 insert into sliding_window01 values ('2023-08-01 00:15:00', 28.0); 135 insert into sliding_window01 values ('2023-08-01 00:20:00', 30.0); 136 insert into sliding_window01 values ('2023-08-01 00:25:00', 27.0); 137 insert into sliding_window01 values ('2023-08-01 00:30:00', null); 138 insert into sliding_window01 values ('2023-08-01 00:35:00', null); 139 insert into sliding_window01 values ('2023-08-01 00:40:00', 28); 140 insert into sliding_window01 values ('2023-08-01 00:45:00', 38); 141 insert into sliding_window01 values ('2023-08-01 00:50:00', 31); 142 insert into sliding_window01 values ('2023-07-31 23:55:00', 22); 143 select * from sliding_window01; 144 select _wstart, _wend, max(col2), min(col2) from sliding_window01 where ts > "2023-08-01 00:00:00.000" and ts < "2023-08-01 00:50:00.000" interval(ts, 10, minute) sliding(5, minute); 145 select _wstart, _wend, max(col2), min(col2) from sliding_window01 where ts > "2023-08-01 00:00:00.000" and ts < "2023-08-01 00:50:00.000" interval(ts, 10, minute) sliding(5, minute) fill(null); 146 select _wstart, _wend, count(col2), avg(col2) from sliding_window01 where ts > "2023-08-01 00:00:00.000" and ts < "2023-08-01 00:50:00.000" interval(ts, 10, minute) sliding(10, minute) fill(next); 147 select _wstart, _wend, count(col2), avg(col2) from sliding_window01 where ts > "2023-08-01 00:00:00.000" and ts < "2023-08-01 00:50:00.000" interval(ts, 10, minute) sliding(6, minute) fill(value,1000); 148 select _wstart, _wend, sum(col2) from sliding_window01 where ts > "2023-08-01 00:00:00.000" and ts < "2023-08-01 00:50:00.000" interval(ts, 1, hour) sliding(10, minute) fill(none); 149 drop table sliding_window01; 150 151 drop table if exists sliding_window02; 152 create table sliding_window02 (ts timestamp primary key , col2 double); 153 insert into sliding_window02 values ('2023-08-01 00:01:01.000',37281932.32143214); 154 insert into sliding_window02 values ('2023-08-01 00:01:02.000',-328934.324); 155 insert into sliding_window02 values ('2023-08-01 00:01:03.000',-23.23232); 156 insert into sliding_window02 values ('2023-08-01 00:01:04.000',null); 157 select * from sliding_window02; 158 select _wstart, _wend, max(col2), min(col2), sum(col2) from sliding_window02 where ts > "2023-08-01 00:01:00.000" and ts < "2023-08-01 00:01:10.000" interval(ts, 1, second) fill(none); 159 select _wstart, _wend, max(col2), min(col2), sum(col2) from sliding_window02 where ts >= "2023-08-01 00:01:00.000" and ts <= "2023-08-01 00:01:10.000" interval(ts, 2, second); 160 select _wstart, _wend, max(col2), min(col2), sum(col2) from sliding_window02 where ts >= "2023-08-01 00:01:00.000" and ts <= "2023-08-01 00:01:10.000" interval(ts, 2, second) fill(prev); 161 select _wstart, _wend, count(col2), avg(col2) from sliding_window02 where ts > "2023-08-01 00:01:00.000" and ts < "2023-08-01 00:01:10.000" interval(ts, 2, second) fill(none); 162 select _wstart, _wend, count(col2), avg(col2) from sliding_window02 where ts > "2023-08-01 00:01:00.000" and ts < "2023-08-01 00:01:10.000" interval(ts, 2, second) fill(linear); 163 select * from sliding_window02; 164 drop table sliding_window02; 165 166 -- time window in prepare 167 drop table if exists sliding_window03; 168 create table sliding_window03 (ts timestamp primary key , col2 float); 169 insert into sliding_window03 values ('2023-08-01 00:01:01.000', 32412.3421); 170 insert into sliding_window03 values ('2023-08-01 00:01:03.000', -23.23232); 171 insert into sliding_window03 values ('2023-08-01 00:01:04.000', -3289.328939201); 172 select * from sliding_window03; 173 prepare s1 from 'select _wstart, _wend, max(col2), min(col2), sum(col2), count(col2), avg(col2) from sliding_window03 where ts > "2023-08-01 00:01:00.000" and ts < "2023-08-01 00:01:10.000" interval(ts, 1, second) fill(none);'; 174 execute s1; 175 prepare s2 from 'select _wstart, _wend, max(col2), min(col2), sum(col2), count(col2), avg(col2) from sliding_window03 where ts > "2023-08-01 00:01:00.000" and ts < "2023-08-01 00:01:10.000" interval(ts, 1, second) sliding(2, second) fill(none);'; 176 execute s2; 177 drop table sliding_window03; 178 179 -- sliding window:interval equal to sliding window 180 drop table if exists sliding_window04; 181 create table sliding_window04 (ts timestamp primary key , col2 double); 182 insert into sliding_window04 values ('2023-08-01 00:01:01.000', 121432421.32142314); 183 insert into sliding_window04 values ('2023-08-01 00:01:03.000', null); 184 insert into sliding_window04 values ('2023-08-01 00:01:04.000', 32151323.32151251252512); 185 insert into sliding_window04 values ('2023-08-01 00:01:05.000', -38298432.32143214231); 186 insert into sliding_window04 values ('2023-08-01 00:01:06.000', 0); 187 insert into sliding_window04 values ('2023-08-01 00:01:07.111', 0); 188 insert into sliding_window04 values ('2023-08-01 00:01:08.123', 38298392.32142142); 189 select * from sliding_window04; 190 select _wstart, _wend, count(col2), avg(col2) from sliding_window04 where ts >= "2023-08-01 00:01:00.000" and ts <= "2023-08-01 00:01:10.000" interval(ts, 1, second) sliding(1, second) fill(prev); 191 select _wstart, _wend, count(col2), avg(col2) from sliding_window04 where ts >= "2023-08-01 00:01:00.000" and ts <= "2023-08-01 00:01:10.000" interval(ts, 2, second) sliding(2, second) fill(next); 192 drop table sliding_window04; 193 194 -- sliding window: fill(null),fill(value,val),fill(LINEAR) 195 drop table if exists sliding_window05; 196 create table sliding_window05 (ts timestamp primary key , col2 int); 197 insert into sliding_window05 values ('2018-01-13 00:01:01.000', 100); 198 insert into sliding_window05 values ('2018-10-13 00:01:02.000', 37213); 199 insert into sliding_window05 values ('2019-01-29 00:10:01.000', -2146261); 200 insert into sliding_window05 values ('2019-12-13 00:11:57.000', 0); 201 insert into sliding_window05 values ('2019-12-13 00:12:58.000', 21132); 202 insert into sliding_window05 values ('2019-02-13 00:13:51.000', null); 203 insert into sliding_window05 values ('2019-12-13 00:13:59.000', null); 204 insert into sliding_window05 values ('2020-12-13 00:21:59.000', null); 205 insert into sliding_window05 values ('2021-12-13 12:12:59.000', null); 206 insert into sliding_window05 values ('2021-12-14 00:11:59.000', -328193471); 207 insert into sliding_window05 values ('2022-07-17 00:04:12.000', -3281891); 208 select * from sliding_window05; 209 select _wstart, _wend, sum(col2) from sliding_window05 where ts >= '1997-01-13 00:00:0.000' and ts <= '2022-07-18 00:04:12.123' interval(ts, 365, day) sliding(200, day) fill(VALUE, 100); 210 select _wstart, _wend, avg(col2) from sliding_window05 where ts >= '1997-01-13 00:00:0.000' and ts <= '2022-07-18 00:04:12.123' interval(ts, 100, day) sliding(100, day) fill(linear); 211 select _wstart, _wend, sum(col2) from sliding_window05 where ts >= '1998-01-29 00:10:01.000' and ts <= '2022-07-17 00:04:12.000' interval(ts, 200, day) sliding(100, day) fill(linear); 212 drop table sliding_window05; 213 214 -- temporary table 215 -- @bvt:issue#12556 216 drop table if exists temporary01; 217 create temporary table temporary01 (ts timestamp primary key, col2 bigint); 218 insert into temporary01 values ('2022-07-17 00:04:12.000', -2147483647); 219 insert into temporary01 values ('2022-08-17 12:23:12.000', null); 220 insert into temporary01 values ('2022-02-15 00:23:12.000', 100); 221 insert into temporary01 values ('2022-09-17 00:23:12.000', 324421432); 222 insert into temporary01 values ('2022-08-27 00:11:12.000', -32434); 223 insert into temporary01 values ('2023-01-01 12:12:12.000', -232); 224 insert into temporary01 values ('2024-03-04 13:14:56.000', -3892323); 225 insert into temporary01 values ('2024-12-12 01:34:46.000', 0); 226 insert into temporary01 values ('2020-10-10 09:09:09.000', null); 227 select * from temporary01; 228 select _wstart, _wend, sum(col2) from temporary01 where ts >= '2020-10-10 09:09:09' and ts <= '2024-12-12 01:34:46' interval(ts, 365, day) sliding(200, day); 229 select _wstart, _wend, avg(col2) from temporary01 where ts >= '2020-10-10 09:09:09' and ts <= '2024-12-12 01:34:46' interval(ts, 365, day) sliding(4800, hour); 230 select _wstart, _wend, max(col2) from temporary01 where ts >= '2020-10-10 09:09:09' and ts <= '2024-12-12 01:34:46' interval(ts, 100, day) sliding(20, day) limit 10; 231 select _wstart, _wend, max(col2) from temporary01 where ts >= '2020-10-10 09:09:09' and ts <= '2024-12-12 01:34:46' interval(ts, 100, day) sliding(28800, minute) limit 10; 232 select _wstart, _wend, max(col2) from temporary01 where ts >= '2020-10-10 09:09:09' and ts <= '2024-12-12 01:34:46' interval(ts, 100, day) sliding(20, day) fill(none); 233 select _wstart, _wend, max(col2) from temporary01 where ts >= '2020-10-10 09:09:09' and ts <= '2024-12-12 01:34:46' interval(ts, 100, day) sliding(28800, minute) fill(prev); 234 select _wstart, _wend, max(col2) from temporary01 where ts >= '2020-10-10 09:09:09' and ts <= '2024-12-12 01:34:46' interval(ts, 100, day) sliding(20, day) fill(next); 235 select _wstart, _wend, max(col2) from temporary01 where ts >= '2020-10-10 09:09:09' and ts <= '2024-12-12 01:34:46' interval(ts, 100, day) sliding(48800, minute) fill (VALUE,10000); 236 -- @bvt:issue 237 -- @bvt:issue#12469 238 select _wstart, _wend, min(col2) from temporary01 where ts >= '2020-10-10 09:09:09' and ts <= '2024-12-12 01:34:46' interval(ts, 365, day) sliding(200, day) fill (linear); 239 -- @bvt:issue 240 -- @bvt:issue#12556 241 drop table temporary01; 242 -- @bvt:issue 243 244 drop table if exists temporary02; 245 create table temporary02 (ts timestamp primary key , col2 double, col3 double, col4 float); 246 insert into temporary02 values ('2023-11-01 00:00:01.000', 100.23242134, 73823.90902, 28392432); 247 insert into temporary02 values ('2023-11-01 00:00:03.000', null, null, null); 248 insert into temporary02 values ('2023-11-01 00:00:04.000', -3921.32421, -3290.32, null); 249 insert into temporary02 values ('2023-11-01 00:00:05.000', -4324, 432424.4324234, 0); 250 insert into temporary02 values ('2023-11-01 00:00:06.000', -38249382324324.990, 4032.432, 90909); 251 insert into temporary02 values ('2023-11-01 00:00:07.000', 212112.3233, 9302, -392032); 252 insert into temporary02 values ('2023-11-01 00:00:08.000', 0, 0, 0); 253 insert into temporary02 values ('2023-11-01 00:00:10.000', 0, null, null); 254 insert into temporary02 values ('2023-11-01 00:00:11.000', 9999.999, 382.343, -32932); 255 insert into temporary02 values ('2023-11-01 00:00:12.000', null, null, -23.4324324); 256 insert into temporary02 values ('2023-11-01 00:01:13.000', -0.1, 328903.32334, 909); 257 insert into temporary02 values ('2023-11-01 00:13:14.000', null, 392432.4324, 8932); 258 select * from temporary02; 259 select _wstart, _wend, max(col2), min(col3) from temporary02 where ts >= '2023-11-01 00:00:01.000' and ts <= '2023-11-01 00:13:14.000' interval(ts, 3, second); 260 select _wstart, _wend, avg(col2), count(col4) from temporary02 where ts >= '2023-11-01 00:00:01.000' and ts <= '2023-11-01 00:13:14.000' interval(ts, 2, second); 261 select _wstart, _wend, avg(col2), count(col4) from temporary02 where ts >= '2023-11-01 00:00:01.000' and ts <= '2023-11-01 00:13:14.000' interval(ts, 2, second) fill(none); 262 select _wstart, _wend, avg(col2), count(col4) from temporary02 where ts >= '2023-11-01 00:00:01.000' and ts <= '2023-11-01 00:13:14.000' interval(ts, 2, second) fill(prev); 263 select _wstart, _wend, avg(col2), count(col4) from temporary02 where ts >= '2023-11-01 00:00:01.000' and ts <= '2023-11-01 00:13:14.000' interval(ts, 2, second) fill(linear); 264 select _wstart, _wend, sum(col3), count(col4) from temporary02 where ts >= '2023-11-01 00:00:01.000' and ts <= '2023-11-01 00:13:14.000' interval(ts, 1, minute); 265 select _wstart, _wend, sum(col3), count(col4) from temporary02 where ts >= '2023-11-01 00:00:01.000' and ts <= '2023-11-01 00:13:14.000' interval(ts, 60, second); 266 select _wstart, _wend, sum(col3), count(col4) from temporary02 where ts >= '2023-11-01 00:00:01.000' and ts <= '2023-11-01 00:13:14.000' interval(ts, 5, second) sliding(4, second) fill(value, 2190); 267 drop table temporary02; 268 269 -- external table 270 drop table if exists external01; 271 create external table external01(ts timestamp primary key,col1 tinyint default null,col2 smallint default null,col3 int default null,col4 bigint default null,col5 tinyint unsigned default null,col6 smallint unsigned default null,col7 int unsigned default null,col8 bigint unsigned default null,col9 float default null,col10 double default null)infile{"filepath"='$resources/external_table_file/time_window.csv'} fields terminated by ',' enclosed by '\"' lines terminated by '\n'; 272 select _wstart, _wend, max(col2), min(col3), avg(col4) from external01 where ts >= '2014-01-01 00:01:17' and ts <= '2014-01-01 00:14:58' interval(ts, 3, minute); 273 select _wstart, _wend, count(col2), sum(col6), avg(col7) from external01 where ts >= '2014-01-01 00:01:17' and ts <= '2014-01-01 00:14:58' interval(ts, 10, minute) sliding(5,minute); 274 select _wstart, _wend, count(col2), sum(col10) from external01 where ts >= '2014-01-01 00:01:17' and ts <= '2014-01-01 00:14:58' interval(ts, 15, minute) sliding(10,minute); 275 select _wstart, _wend, count(col2), sum(col10) from external01 where ts >= '2014-01-01 00:01:17' and ts <= '2014-01-01 00:14:58' interval(ts, 15, minute) sliding(10,minute) fill(value,1000); 276 drop table external01; 277 278 drop table if exists tt1; 279 create table tt1(ts timestamp primary key, a int); 280 select max(a) as enable, min(a) as collation from tt1 interval(ts, 1, minute); 281 282 drop database time_window;