Skip to content

Commit 983e927

Browse files
authored
Add M4 table function implementation and integrate with statement ana… (#17656)
1 parent 3030597 commit 983e927

6 files changed

Lines changed: 1475 additions & 2 deletions

File tree

integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java

Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,31 @@ public class IoTDBWindowTVFIT {
6262
"insert into multi_type values (2021-01-01T09:05:00, 'device1', 3, 3, 3.0, 3.0, false, '2', X'02', 2021-01-01T10:00:00, '2021-01-02')",
6363
"create table t1 (value double field, value1 int32 field)",
6464
"insert into t1 values (1, 1, 0),(2, 2, 0),(3, 1, 0),(4, 1, 0),(5, 1, 0),(6, 1.2, 0),(7, 1, 0),(8, 1, 0),(9, 2, 0),(10, 3, 0),(11, 4, 0),(12, 3, 0),(13, 2, 0),(14, 3, 0),(15, 4, 0),(16, 2, 0),(17, 1, 0),(18, 1, 0),(19, 1, 0),(20, 1, 0),(21, 1, 0),(41, 1, 0),(42, 2, 0),(43, 3, 0),(44, 4, 0),(45, 3, 0),(46, 2, 0),(47, 2, 0),(48, 2, 0),(49, 2, 0),(50, 2, 0),(51, 2, 0),(52, 2, 0)",
65+
// M4 table function test data
66+
"CREATE TABLE table1(device_id STRING TAG, s1 DOUBLE FIELD, s2 DOUBLE FIELD, s3 STRING FIELD)",
67+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.001+08:00, 'device_1', 15.0, 12.0, 'OK')",
68+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.003+08:00, 'device_1', 5.0, null, 'OK')",
69+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.006+08:00, 'device_1', 30.0, null, 'WARN')",
70+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.009+08:00, 'device_1', 10.0, null, 'OK')",
71+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.020+08:00, 'device_1', 40.0, 35.0, 'CRIT')",
72+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.002+08:00, 'device_2', 8.0, 8.0, 'OK')",
73+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.005+08:00, 'device_2', 25.0, 24.0, 'WARN')",
74+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.008+08:00, 'device_2', 12.0, 13.0, 'OK')",
75+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.011+08:00, 'device_2', 18.0, 19.0, 'OK')",
76+
"INSERT INTO table1(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.015+08:00, 'device_2', 6.0, 7.0, 'WARN')",
77+
"CREATE TABLE table3(device_id STRING TAG, s1 DOUBLE FIELD, s2 DOUBLE FIELD, s3 STRING FIELD)",
78+
"INSERT INTO table3(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.001+08:00, 'device_1', null, null, null)",
79+
"INSERT INTO table3(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.003+08:00, 'device_1', null, null, null)",
80+
"INSERT INTO table3(time, device_id, s1, s2, s3) VALUES (1970-01-01T08:00:00.020+08:00, 'device_1', 40.0, 35.0, 'CRIT')",
81+
"CREATE TABLE table4(device_id STRING TAG, object_col BLOB FIELD)",
82+
"INSERT INTO table4(time, device_id, object_col) VALUES (1970-01-01T08:00:00.001+08:00, 'device_1', X'0102')",
83+
"CREATE TABLE table5(factory_id STRING TAG, device_id STRING TAG, s1 DOUBLE FIELD)",
84+
"INSERT INTO table5(time, factory_id, device_id, s1) VALUES (1970-01-01T08:00:00.001+08:00, 'F1', 'device_1', 10.0)",
85+
"INSERT INTO table5(time, factory_id, device_id, s1) VALUES (1970-01-01T08:00:00.005+08:00, 'F1', 'device_1', 15.0)",
86+
"INSERT INTO table5(time, factory_id, device_id, s1) VALUES (1970-01-01T08:00:00.009+08:00, 'F1', 'device_1', 5.0)",
87+
"INSERT INTO table5(time, factory_id, device_id, s1) VALUES (1970-01-01T08:00:00.002+08:00, 'F1', 'device_2', 20.0)",
88+
"INSERT INTO table5(time, factory_id, device_id, s1) VALUES (1970-01-01T08:00:00.011+08:00, 'F1', 'device_2', 25.0)",
89+
"INSERT INTO table5(time, factory_id, device_id, s1) VALUES (1970-01-01T08:00:00.003+08:00, 'F2', 'device_1', 30.0)",
6590
"FLUSH",
6691
"CLEAR ATTRIBUTE CACHE",
6792
};
@@ -1013,4 +1038,313 @@ public void testPatternMatchFunction() {
10131038
"Invalid pattern",
10141039
DATABASE_NAME);
10151040
}
1041+
1042+
@Test
1043+
public void testM4TimeWindowMode() {
1044+
String[] expectedHeader =
1045+
new String[] {
1046+
"window_start",
1047+
"window_end",
1048+
"device_id",
1049+
"s1_time",
1050+
"s1",
1051+
"s2_time",
1052+
"s2",
1053+
"s3_time",
1054+
"s3"
1055+
};
1056+
String[] retArray =
1057+
new String[] {
1058+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.001Z,15.0,1970-01-01T00:00:00.001Z,12.0,1970-01-01T00:00:00.001Z,OK,",
1059+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.003Z,5.0,null,null,1970-01-01T00:00:00.006Z,WARN,",
1060+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.006Z,30.0,null,null,1970-01-01T00:00:00.009Z,OK,",
1061+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.009Z,10.0,null,null,null,null,",
1062+
"1970-01-01T00:00:00.020Z,1970-01-01T00:00:00.030Z,device_1,1970-01-01T00:00:00.020Z,40.0,1970-01-01T00:00:00.020Z,35.0,1970-01-01T00:00:00.020Z,CRIT,",
1063+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_2,1970-01-01T00:00:00.002Z,8.0,1970-01-01T00:00:00.002Z,8.0,1970-01-01T00:00:00.002Z,OK,",
1064+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_2,1970-01-01T00:00:00.005Z,25.0,1970-01-01T00:00:00.005Z,24.0,1970-01-01T00:00:00.005Z,WARN,",
1065+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_2,1970-01-01T00:00:00.008Z,12.0,1970-01-01T00:00:00.008Z,13.0,1970-01-01T00:00:00.008Z,OK,",
1066+
"1970-01-01T00:00:00.010Z,1970-01-01T00:00:00.020Z,device_2,1970-01-01T00:00:00.011Z,18.0,1970-01-01T00:00:00.011Z,19.0,1970-01-01T00:00:00.011Z,OK,",
1067+
"1970-01-01T00:00:00.010Z,1970-01-01T00:00:00.020Z,device_2,1970-01-01T00:00:00.015Z,6.0,1970-01-01T00:00:00.015Z,7.0,1970-01-01T00:00:00.015Z,WARN,"
1068+
};
1069+
tableResultSetEqualTest(
1070+
"SELECT window_start, window_end, device_id, s1_time, s1, s2_time, s2, s3_time, s3 "
1071+
+ "FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, "
1072+
+ "TIMECOL => 'time', SIZE => 10ms) "
1073+
+ "ORDER BY device_id, window_start, s1_time",
1074+
expectedHeader,
1075+
retArray,
1076+
DATABASE_NAME);
1077+
}
1078+
1079+
@Test
1080+
public void testM4TimeWindowModeSelectStar() {
1081+
String[] expectedHeader =
1082+
new String[] {
1083+
"window_start",
1084+
"window_end",
1085+
"device_id",
1086+
"s1_time",
1087+
"s1",
1088+
"s2_time",
1089+
"s2",
1090+
"s3_time",
1091+
"s3"
1092+
};
1093+
String[] retArray =
1094+
new String[] {
1095+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.001Z,15.0,1970-01-01T00:00:00.001Z,12.0,1970-01-01T00:00:00.001Z,OK,",
1096+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.003Z,5.0,null,null,1970-01-01T00:00:00.006Z,WARN,",
1097+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.006Z,30.0,null,null,1970-01-01T00:00:00.009Z,OK,",
1098+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.009Z,10.0,null,null,null,null,",
1099+
"1970-01-01T00:00:00.020Z,1970-01-01T00:00:00.030Z,device_1,1970-01-01T00:00:00.020Z,40.0,1970-01-01T00:00:00.020Z,35.0,1970-01-01T00:00:00.020Z,CRIT,",
1100+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_2,1970-01-01T00:00:00.002Z,8.0,1970-01-01T00:00:00.002Z,8.0,1970-01-01T00:00:00.002Z,OK,",
1101+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_2,1970-01-01T00:00:00.005Z,25.0,1970-01-01T00:00:00.005Z,24.0,1970-01-01T00:00:00.005Z,WARN,",
1102+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_2,1970-01-01T00:00:00.008Z,12.0,1970-01-01T00:00:00.008Z,13.0,1970-01-01T00:00:00.008Z,OK,",
1103+
"1970-01-01T00:00:00.010Z,1970-01-01T00:00:00.020Z,device_2,1970-01-01T00:00:00.011Z,18.0,1970-01-01T00:00:00.011Z,19.0,1970-01-01T00:00:00.011Z,OK,",
1104+
"1970-01-01T00:00:00.010Z,1970-01-01T00:00:00.020Z,device_2,1970-01-01T00:00:00.015Z,6.0,1970-01-01T00:00:00.015Z,7.0,1970-01-01T00:00:00.015Z,WARN,"
1105+
};
1106+
tableResultSetEqualTest(
1107+
"SELECT * "
1108+
+ "FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, "
1109+
+ "TIMECOL => 'time', SIZE => 10ms) "
1110+
+ "ORDER BY device_id, window_start, s1_time",
1111+
expectedHeader,
1112+
retArray,
1113+
DATABASE_NAME);
1114+
}
1115+
1116+
@Test
1117+
public void testM4TimeWindowModeByPosition() {
1118+
String[] expectedHeader =
1119+
new String[] {"window_start", "window_end", "device_id", "s1_time", "s1"};
1120+
String[] retArray =
1121+
new String[] {
1122+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.001Z,15.0,",
1123+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.003Z,5.0,",
1124+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.006Z,30.0,",
1125+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,device_1,1970-01-01T00:00:00.009Z,10.0,"
1126+
};
1127+
tableResultSetEqualTest(
1128+
"SELECT window_start, window_end, device_id, s1_time, s1 "
1129+
+ "FROM M4(table1 PARTITION BY device_id ORDER BY time, 'time', 10ms) "
1130+
+ "WHERE device_id = 'device_1' AND window_start = 0 "
1131+
+ "ORDER BY s1_time",
1132+
expectedHeader,
1133+
retArray,
1134+
DATABASE_NAME);
1135+
}
1136+
1137+
@Test
1138+
public void testM4TimeWindowWithSlide() {
1139+
String[] expectedHeader =
1140+
new String[] {
1141+
"window_start",
1142+
"window_end",
1143+
"device_id",
1144+
"s1_time",
1145+
"s1",
1146+
"s2_time",
1147+
"s2",
1148+
"s3_time",
1149+
"s3"
1150+
};
1151+
String[] retArray =
1152+
new String[] {
1153+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.005Z,device_1,1970-01-01T00:00:00.001Z,15.0,1970-01-01T00:00:00.001Z,12.0,1970-01-01T00:00:00.001Z,OK,",
1154+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.005Z,device_1,1970-01-01T00:00:00.003Z,5.0,null,null,1970-01-01T00:00:00.003Z,OK,",
1155+
"1970-01-01T00:00:00.020Z,1970-01-01T00:00:00.025Z,device_1,1970-01-01T00:00:00.020Z,40.0,1970-01-01T00:00:00.020Z,35.0,1970-01-01T00:00:00.020Z,CRIT,",
1156+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.005Z,device_2,1970-01-01T00:00:00.002Z,8.0,1970-01-01T00:00:00.002Z,8.0,1970-01-01T00:00:00.002Z,OK,",
1157+
"1970-01-01T00:00:00.010Z,1970-01-01T00:00:00.015Z,device_2,1970-01-01T00:00:00.011Z,18.0,1970-01-01T00:00:00.011Z,19.0,1970-01-01T00:00:00.011Z,OK,"
1158+
};
1159+
tableResultSetEqualTest(
1160+
"SELECT window_start, window_end, device_id, s1_time, s1, s2_time, s2, s3_time, s3 "
1161+
+ "FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, "
1162+
+ "TIMECOL => 'time', SIZE => 5ms, SLIDE => 10ms) "
1163+
+ "ORDER BY device_id, window_start, s1_time",
1164+
expectedHeader,
1165+
retArray,
1166+
DATABASE_NAME);
1167+
}
1168+
1169+
@Test
1170+
public void testM4CountWindowMode() {
1171+
String[] expectedHeader =
1172+
new String[] {
1173+
"window_index", "device_id", "s1_time", "s1", "s2_time", "s2", "s3_time", "s3"
1174+
};
1175+
String[] retArray =
1176+
new String[] {
1177+
"0,device_1,1970-01-01T00:00:00.001Z,15.0,1970-01-01T00:00:00.001Z,12.0,1970-01-01T00:00:00.001Z,OK,",
1178+
"0,device_1,1970-01-01T00:00:00.003Z,5.0,null,null,1970-01-01T00:00:00.003Z,OK,",
1179+
"1,device_1,1970-01-01T00:00:00.006Z,30.0,null,null,1970-01-01T00:00:00.006Z,WARN,",
1180+
"1,device_1,1970-01-01T00:00:00.009Z,10.0,null,null,1970-01-01T00:00:00.009Z,OK,",
1181+
"2,device_1,1970-01-01T00:00:00.020Z,40.0,1970-01-01T00:00:00.020Z,35.0,1970-01-01T00:00:00.020Z,CRIT,",
1182+
"0,device_2,1970-01-01T00:00:00.002Z,8.0,1970-01-01T00:00:00.002Z,8.0,1970-01-01T00:00:00.002Z,OK,",
1183+
"0,device_2,1970-01-01T00:00:00.005Z,25.0,1970-01-01T00:00:00.005Z,24.0,1970-01-01T00:00:00.005Z,WARN,",
1184+
"1,device_2,1970-01-01T00:00:00.008Z,12.0,1970-01-01T00:00:00.008Z,13.0,1970-01-01T00:00:00.008Z,OK,",
1185+
"1,device_2,1970-01-01T00:00:00.011Z,18.0,1970-01-01T00:00:00.011Z,19.0,1970-01-01T00:00:00.011Z,OK,",
1186+
"2,device_2,1970-01-01T00:00:00.015Z,6.0,1970-01-01T00:00:00.015Z,7.0,1970-01-01T00:00:00.015Z,WARN,"
1187+
};
1188+
tableResultSetEqualTest(
1189+
"SELECT * "
1190+
+ "FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, "
1191+
+ "TIMECOL => 'time', SIZE => 2) "
1192+
+ "ORDER BY device_id, window_index, s1_time",
1193+
expectedHeader,
1194+
retArray,
1195+
DATABASE_NAME);
1196+
}
1197+
1198+
@Test
1199+
public void testM4Origin() {
1200+
String[] expectedHeader =
1201+
new String[] {"window_start", "window_end", "device_id", "s1_time", "s1"};
1202+
String[] retArray =
1203+
new String[] {
1204+
"1969-12-31T23:59:59.995Z,1970-01-01T00:00:00.005Z,device_1,1970-01-01T00:00:00.001Z,15.0,",
1205+
"1969-12-31T23:59:59.995Z,1970-01-01T00:00:00.005Z,device_1,1970-01-01T00:00:00.003Z,5.0,",
1206+
"1970-01-01T00:00:00.005Z,1970-01-01T00:00:00.015Z,device_1,1970-01-01T00:00:00.006Z,30.0,",
1207+
"1970-01-01T00:00:00.005Z,1970-01-01T00:00:00.015Z,device_1,1970-01-01T00:00:00.009Z,10.0,",
1208+
"1970-01-01T00:00:00.015Z,1970-01-01T00:00:00.025Z,device_1,1970-01-01T00:00:00.020Z,40.0,"
1209+
};
1210+
tableResultSetEqualTest(
1211+
"SELECT window_start, window_end, device_id, s1_time, s1 "
1212+
+ "FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, "
1213+
+ "TIMECOL => 'time', ORIGIN => 1970-01-01T08:00:00.005+08:00, SIZE => 10ms) "
1214+
+ "WHERE device_id = 'device_1' ORDER BY window_start, s1_time",
1215+
expectedHeader,
1216+
retArray,
1217+
DATABASE_NAME);
1218+
}
1219+
1220+
@Test
1221+
public void testM4MultiplePartitionColumns() {
1222+
String[] expectedHeader =
1223+
new String[] {"window_start", "window_end", "factory_id", "device_id", "s1_time", "s1"};
1224+
String[] retArray =
1225+
new String[] {
1226+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,F1,device_1,1970-01-01T00:00:00.001Z,10.0,",
1227+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,F1,device_1,1970-01-01T00:00:00.005Z,15.0,",
1228+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,F1,device_1,1970-01-01T00:00:00.009Z,5.0,",
1229+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,F1,device_2,1970-01-01T00:00:00.002Z,20.0,",
1230+
"1970-01-01T00:00:00.010Z,1970-01-01T00:00:00.020Z,F1,device_2,1970-01-01T00:00:00.011Z,25.0,",
1231+
"1970-01-01T00:00:00.000Z,1970-01-01T00:00:00.010Z,F2,device_1,1970-01-01T00:00:00.003Z,30.0,"
1232+
};
1233+
tableResultSetEqualTest(
1234+
"SELECT window_start, window_end, factory_id, device_id, s1_time, s1 "
1235+
+ "FROM M4(DATA => table5 PARTITION BY (factory_id, device_id) ORDER BY time, "
1236+
+ "TIMECOL => 'time', SIZE => 10ms) "
1237+
+ "ORDER BY factory_id, device_id, window_start, s1_time",
1238+
expectedHeader,
1239+
retArray,
1240+
DATABASE_NAME);
1241+
}
1242+
1243+
@Test
1244+
public void testM4AllNullWindowSkipped() {
1245+
String[] expectedHeader =
1246+
new String[] {
1247+
"window_start",
1248+
"window_end",
1249+
"device_id",
1250+
"s1_time",
1251+
"s1",
1252+
"s2_time",
1253+
"s2",
1254+
"s3_time",
1255+
"s3"
1256+
};
1257+
String[] retArray =
1258+
new String[] {
1259+
"1970-01-01T00:00:00.020Z,1970-01-01T00:00:00.030Z,device_1,1970-01-01T00:00:00.020Z,40.0,1970-01-01T00:00:00.020Z,35.0,1970-01-01T00:00:00.020Z,CRIT,"
1260+
};
1261+
tableResultSetEqualTest(
1262+
"SELECT window_start, window_end, device_id, s1_time, s1, s2_time, s2, s3_time, s3 "
1263+
+ "FROM M4(DATA => table3 PARTITION BY device_id ORDER BY time, "
1264+
+ "TIMECOL => 'time', SIZE => 10ms) "
1265+
+ "ORDER BY device_id, window_start, s1_time",
1266+
expectedHeader,
1267+
retArray,
1268+
DATABASE_NAME);
1269+
}
1270+
1271+
@Test
1272+
public void testM4MissingSize() {
1273+
tableAssertTestFail(
1274+
"SELECT * FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, TIMECOL => 'time')",
1275+
"701: Missing required argument: SIZE",
1276+
DATABASE_NAME);
1277+
}
1278+
1279+
@Test
1280+
public void testM4MissingOrderBy() {
1281+
tableAssertTestFail(
1282+
"SELECT * FROM M4(DATA => table1 PARTITION BY device_id, TIMECOL => 'time', SIZE => 10ms)",
1283+
"701: Table argument with set semantics requires an ORDER BY clause.",
1284+
DATABASE_NAME);
1285+
}
1286+
1287+
@Test
1288+
public void testM4UnexpectedOrderBy() {
1289+
tableAssertTestFail(
1290+
"SELECT * FROM M4(DATA => table1 PARTITION BY device_id ORDER BY s1, TIMECOL => 'time', SIZE => 10ms)",
1291+
"701: The ORDER BY clause of the DATA argument must contain exactly the time column specified by the TIMECOL argument.",
1292+
DATABASE_NAME);
1293+
}
1294+
1295+
@Test
1296+
public void testM4TimeColumnNotFound() {
1297+
tableAssertTestFail(
1298+
"SELECT * FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, TIMECOL => 'timestamp', SIZE => 10ms)",
1299+
"701: Required column [timestamp] not found in the source table argument.",
1300+
DATABASE_NAME);
1301+
}
1302+
1303+
@Test
1304+
public void testM4IllegalValueType() {
1305+
tableAssertTestFail(
1306+
"SELECT * FROM M4(DATA => table4 PARTITION BY device_id ORDER BY time, TIMECOL => 'time', SIZE => 10ms)",
1307+
"701: The type of the column [object_col] is not comparable.",
1308+
DATABASE_NAME);
1309+
}
1310+
1311+
@Test
1312+
public void testM4CountWindowRejectsOrigin() {
1313+
tableAssertTestFail(
1314+
"SELECT * FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, TIMECOL => 'time', SIZE => 5, ORIGIN => 1970-01-01T08:00:00.000+08:00)",
1315+
"701: The ORIGIN argument is only supported in time window mode.",
1316+
DATABASE_NAME);
1317+
}
1318+
1319+
@Test
1320+
public void testM4DescendingOrderByRejected() {
1321+
tableAssertTestFail(
1322+
"SELECT * FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time DESC, TIMECOL => 'time', SIZE => 10ms)",
1323+
"701: The ORDER BY clause of the DATA argument must sort the time column in ascending order.",
1324+
DATABASE_NAME);
1325+
}
1326+
1327+
@Test
1328+
public void testM4RejectsNegativeSize() {
1329+
tableAssertTestFail(
1330+
"SELECT * FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, TIMECOL => 'time', SIZE => -1)",
1331+
"701: Invalid scalar argument SIZE, should be a positive value",
1332+
DATABASE_NAME);
1333+
}
1334+
1335+
@Test
1336+
public void testM4RejectsFloatSize() {
1337+
tableAssertTestFail(
1338+
"SELECT * FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, TIMECOL => 'time', SIZE => 1.5)",
1339+
"701: Invalid scalar argument 'SIZE'. Expected type INT64, got Double",
1340+
DATABASE_NAME);
1341+
}
1342+
1343+
@Test
1344+
public void testM4RejectsNonTimestampTimecol() {
1345+
tableAssertTestFail(
1346+
"SELECT * FROM M4(DATA => table1 PARTITION BY device_id ORDER BY time, TIMECOL => 's1', SIZE => 10ms)",
1347+
"701: The type of the column [s1] is not as expected.",
1348+
DATABASE_NAME);
1349+
}
10161350
}

0 commit comments

Comments
 (0)