4747import static org .apache .iotdb .db .it .utils .TestUtils .defaultFormatDataTime ;
4848import static org .apache .iotdb .db .it .utils .TestUtils .prepareTableData ;
4949import static org .apache .iotdb .db .it .utils .TestUtils .tableAssertTestFail ;
50+ import static org .apache .iotdb .db .it .utils .TestUtils .tableResultSetEqualTest ;
5051import static org .junit .Assert .fail ;
5152
5253@ RunWith (IoTDBTestRunner .class )
@@ -57,19 +58,19 @@ public class IoTDBInTableIT {
5758 new String [] {
5859 "CREATE DATABASE " + DATABASE_NAME ,
5960 "USE " + DATABASE_NAME ,
60- "CREATE TABLE sg(device1 STRING ID, device2 STRING ID, qrcode TEXT MEASUREMENT, date_v DATE MEASUREMENT, blob_v BLOB MEASUREMENT)" ,
61- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465600000,'d1','s1','qrcode001', '2024-08-01', X'abc0')" ,
62- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465660000,'d1','s1','qrcode002', '2024-08-02', X'abc1')" ,
63- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465720000,'d1','s1','qrcode003', '2024-08-03', X'abc2')" ,
64- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465780000,'d1','s1','qrcode004', '2024-08-04', X'abc3')" ,
65- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465720000,'d1','s2','qrcode002', '2024-08-05', X'abc4')" ,
66- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465780000,'d1','s2','qrcode003', '2024-08-06', X'abc5')" ,
67- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465840000,'d1','s2','qrcode004', '2024-08-07', X'abc6')" ,
68- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465900000,'d1','s2','qrcode005', '2024-08-08', X'abc7')" ,
69- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465780000,'d2','s1','qrcode002', '2024-08-09', X'abc8')" ,
70- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465840000,'d2','s1','qrcode003', '2024-08-10', X'abc9')" ,
71- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465900000,'d2','s1','qrcode004', '2024-08-11', X'abca')" ,
72- "insert into sg(time,device1,device2,qrcode,date_v,blob_v) values(1509465960000,'d2','s1','qrcode005', '2024-08-12', X'abcb')" ,
61+ "CREATE TABLE sg(device1 STRING ID, device2 STRING ID, qrcode TEXT MEASUREMENT, date_v DATE MEASUREMENT, blob_v BLOB MEASUREMENT, timestamp_v TIMESTAMP MEASUREMENT )" ,
62+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465600000,'d1','s1','qrcode001', '2024-08-01', X'abc0',1509465600000 )" ,
63+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465660000,'d1','s1','qrcode002', '2024-08-02', X'abc1',1509465660000 )" ,
64+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465720000,'d1','s1','qrcode003', '2024-08-03', X'abc2',1509465720000 )" ,
65+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465780000,'d1','s1','qrcode004', '2024-08-04', X'abc3',1509465780000 )" ,
66+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465720000,'d1','s2','qrcode002', '2024-08-05', X'abc4',1509465720000 )" ,
67+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465780000,'d1','s2','qrcode003', '2024-08-06', X'abc5',1509465780000 )" ,
68+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465840000,'d1','s2','qrcode004', '2024-08-07', X'abc6',1509465840000 )" ,
69+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465900000,'d1','s2','qrcode005', '2024-08-08', X'abc7',1509465900000 )" ,
70+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465780000,'d2','s1','qrcode002', '2024-08-09', X'abc8',1509465780000 )" ,
71+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465840000,'d2','s1','qrcode003', '2024-08-10', X'abc9',1509465840000 )" ,
72+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465900000,'d2','s1','qrcode004', '2024-08-11', X'abca',1509465900000 )" ,
73+ "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v ) values(1509465960000,'d2','s1','qrcode005', '2024-08-12', X'abcb',1509465960000 )" ,
7374 "CREATE TABLE table1(device STRING ID, s1 INT32 MEASUREMENT, s2 INT64 MEASUREMENT, s3 FLOAT MEASUREMENT, s4 DOUBLE MEASUREMENT, s5 BOOLEAN MEASUREMENT)" ,
7475 };
7576
@@ -215,6 +216,68 @@ public void selectWithAlignByDeviceTest() {
215216 }
216217 }
217218
219+ @ Test
220+ public void testTimestampIn () {
221+ // select time,device1,device2,timestamp_v from sg where timestamp_v in (1509465600000)
222+ // 1509465600000,'d1','s1',
223+ String [] expectedHeader = new String [] {"time" , "device1" , "device2" , "timestamp_v" };
224+ String [] retArray =
225+ new String [] {
226+ "2017-10-31T16:00:00.000Z,d1,s1,2017-10-31T16:00:00.000Z," ,
227+ };
228+ tableResultSetEqualTest (
229+ "select time,device1,device2,timestamp_v from sg where timestamp_v in (1509465600000)" ,
230+ expectedHeader ,
231+ retArray ,
232+ DATABASE_NAME );
233+
234+ tableResultSetEqualTest (
235+ "select time,device1,device2,timestamp_v from sg where timestamp_v=1509465600000" ,
236+ expectedHeader ,
237+ retArray ,
238+ DATABASE_NAME );
239+
240+ tableResultSetEqualTest (
241+ "select time,device1,device2,timestamp_v from sg where timestamp_v=2017-11-01T00:00:00.000+08:00" ,
242+ expectedHeader ,
243+ retArray ,
244+ DATABASE_NAME );
245+ tableResultSetEqualTest (
246+ "select time,device1,device2,timestamp_v from sg where timestamp_v=CAST('2017-11-01T00:00:00.000+08:00' AS TIMESTAMP)" ,
247+ expectedHeader ,
248+ retArray ,
249+ DATABASE_NAME );
250+
251+ tableResultSetEqualTest (
252+ "select time,device1,device2,timestamp_v from sg where timestamp_v in (1509465600000.0)" ,
253+ expectedHeader ,
254+ retArray ,
255+ DATABASE_NAME );
256+
257+ tableResultSetEqualTest (
258+ "select time,device1,device2,timestamp_v from sg where timestamp_v=1509465600000.0" ,
259+ expectedHeader ,
260+ retArray ,
261+ DATABASE_NAME );
262+
263+ retArray =
264+ new String [] {
265+ "2017-10-31T16:03:00.000Z,d1,s1,2017-10-31T16:03:00.000Z," ,
266+ "2017-10-31T16:03:00.000Z,d1,s2,2017-10-31T16:03:00.000Z," ,
267+ "2017-10-31T16:04:00.000Z,d1,s2,2017-10-31T16:04:00.000Z," ,
268+ "2017-10-31T16:05:00.000Z,d1,s2,2017-10-31T16:05:00.000Z," ,
269+ "2017-10-31T16:03:00.000Z,d2,s1,2017-10-31T16:03:00.000Z," ,
270+ "2017-10-31T16:04:00.000Z,d2,s1,2017-10-31T16:04:00.000Z," ,
271+ "2017-10-31T16:05:00.000Z,d2,s1,2017-10-31T16:05:00.000Z," ,
272+ "2017-10-31T16:06:00.000Z,d2,s1,2017-10-31T16:06:00.000Z," ,
273+ };
274+ tableResultSetEqualTest (
275+ "select time,device1,device2,timestamp_v from sg where timestamp_v not in (2017-11-01T00:00:00.000+08:00,1509465660000.0,CAST('2017-11-01T00:02:00.000+08:00' AS TIMESTAMP)) order by device1,device2,time" ,
276+ expectedHeader ,
277+ retArray ,
278+ DATABASE_NAME );
279+ }
280+
218281 private List <Integer > checkHeader (
219282 ResultSetMetaData resultSetMetaData , String expectedHeaderStrings , int [] expectedTypes )
220283 throws SQLException {
0 commit comments