@@ -1251,4 +1251,146 @@ def test_select_day_of_week(self, suffix):
1251
1251
assert res ['dayofweek(c3)' ][0 ] == 4 , "The value of day_of_week(c3) should be 4"
1252
1252
1253
1253
res = db_obj .drop_table ("test_select_day_of_week" + suffix )
1254
- assert res .error_code == ErrorCode .OK
1254
+ assert res .error_code == ErrorCode .OK
1255
+
1256
+ def test_select_weekday (self , suffix ):
1257
+ db_obj = self .infinity_obj .get_database ("default_db" )
1258
+ db_obj .drop_table ("test_select_weekday" + suffix , ConflictType .Ignore )
1259
+ db_obj .create_table ("test_select_weekday" + suffix ,
1260
+ {"c1" : {"type" : "date" },
1261
+ "c2" : {"type" : "datetime" },
1262
+ "c3" : {"type" : "timestamp" }}, ConflictType .Error )
1263
+ table_obj = db_obj .get_table ("test_select_weekday" + suffix )
1264
+ table_obj .insert (
1265
+ [{"c1" :"2025-01-16" , "c2" : "2025-01-31 21:44:33" , "c3" :"2025-01-26 20:45:11" }])
1266
+
1267
+ res , extra_res = table_obj .output (["weekday(c1)" , "weekday(c2)" , "weekday(c3)" ]).to_pl ()
1268
+ print (res )
1269
+ assert res ['weekday(c1)' ][0 ] == 4 , "The value of weekday(c1) should be 4"
1270
+ assert res ['weekday(c2)' ][0 ] == 5 , "The value of weekday(c2) should be 5"
1271
+ assert res ['weekday(c3)' ][0 ] == 0 , "The value of weekday(c3) should be 0"
1272
+
1273
+ res = db_obj .drop_table ("test_select_weekday" + suffix )
1274
+ assert res .error_code == ErrorCode .OK
1275
+
1276
+ def test_select_era (self , suffix ):
1277
+ db_obj = self .infinity_obj .get_database ("default_db" )
1278
+ db_obj .drop_table ("test_select_era" + suffix , ConflictType .Ignore )
1279
+ db_obj .create_table ("test_select_era" + suffix ,
1280
+ {"c1" : {"type" : "date" },
1281
+ "c2" : {"type" : "datetime" },
1282
+ "c3" : {"type" : "timestamp" }}, ConflictType .Error )
1283
+ table_obj = db_obj .get_table ("test_select_era" + suffix )
1284
+ table_obj .insert (
1285
+ [{"c1" :"2025-01-16" , "c2" : "44-01-16 21:44:33" , "c3" :"-25-01-16 20:45:11" }])
1286
+
1287
+ res , extra_res = table_obj .output (["era(c1)" , "era(c2)" , "era(c3)" ]).to_pl ()
1288
+ print (res )
1289
+ assert res ['era(c1)' ][0 ] == 1 , "The value of era(c1) should be 1"
1290
+ assert res ['era(c2)' ][0 ] == 1 , "The value of era(c2) should be 1"
1291
+ assert res ['era(c3)' ][0 ] == 0 , "The value of era(c3) should be 0"
1292
+
1293
+ res = db_obj .drop_table ("test_select_era" + suffix )
1294
+ assert res .error_code == ErrorCode .OK
1295
+
1296
+ def test_select_epoch (self , suffix ):
1297
+ db_obj = self .infinity_obj .get_database ("default_db" )
1298
+ db_obj .drop_table ("test_select_epoch" + suffix , ConflictType .Ignore )
1299
+ db_obj .create_table ("test_select_epoch" + suffix ,
1300
+ {"c1" : {"type" : "date" },
1301
+ "c2" : {"type" : "datetime" },
1302
+ "c3" : {"type" : "timestamp" }}, ConflictType .Error )
1303
+ table_obj = db_obj .get_table ("test_select_epoch" + suffix )
1304
+ table_obj .insert (
1305
+ [{"c1" :"1970-01-01" , "c2" : "1970-01-01 21:44:33" , "c3" :"1970-01-01 20:45:11" }])
1306
+
1307
+ res , extra_res = table_obj .output (["epoch(c1)" , "epoch(c2)" , "epoch(c3)" ]).to_pl ()
1308
+ print (res )
1309
+ assert res ['epoch(c1)' ][0 ] == 0 , "The value of epoch(c1) should be 0"
1310
+ assert res ['epoch(c2)' ][0 ] == 78273 , "The value of epoch(c2) should be 78273"
1311
+ assert res ['epoch(c3)' ][0 ] == 74711 , "The value of epoch(c3) should be 74711"
1312
+
1313
+ res = db_obj .drop_table ("test_select_epoch" + suffix )
1314
+ assert res .error_code == ErrorCode .OK
1315
+
1316
+ def test_select_quarter (self , suffix ):
1317
+ db_obj = self .infinity_obj .get_database ("default_db" )
1318
+ db_obj .drop_table ("test_select_quarter" + suffix , ConflictType .Ignore )
1319
+ db_obj .create_table ("test_select_quarter" + suffix ,
1320
+ {"c1" : {"type" : "date" },
1321
+ "c2" : {"type" : "datetime" },
1322
+ "c3" : {"type" : "timestamp" }}, ConflictType .Error )
1323
+ table_obj = db_obj .get_table ("test_select_quarter" + suffix )
1324
+ table_obj .insert (
1325
+ [{"c1" :"2025-01-16" , "c2" : "2025-04-16 21:44:33" , "c3" :"2025-09-16 20:45:11" }])
1326
+
1327
+ res , extra_res = table_obj .output (["quarter(c1)" , "quarter(c2)" , "quarter(c3)" ]).to_pl ()
1328
+ print (res )
1329
+ assert res ['quarter(c1)' ][0 ] == 1 , "The value of quarter(c1) should be 1"
1330
+ assert res ['quarter(c2)' ][0 ] == 2 , "The value of quarter(c2) should be 2"
1331
+ assert res ['quarter(c3)' ][0 ] == 3 , "The value of quarter(c3) should be 3"
1332
+
1333
+ res = db_obj .drop_table ("test_select_quarter" + suffix )
1334
+ assert res .error_code == ErrorCode .OK
1335
+
1336
+ def test_select_century (self , suffix ):
1337
+ db_obj = self .infinity_obj .get_database ("default_db" )
1338
+ db_obj .drop_table ("test_select_century" + suffix , ConflictType .Ignore )
1339
+ db_obj .create_table ("test_select_century" + suffix ,
1340
+ {"c1" : {"type" : "date" },
1341
+ "c2" : {"type" : "datetime" },
1342
+ "c3" : {"type" : "timestamp" }}, ConflictType .Error )
1343
+ table_obj = db_obj .get_table ("test_select_century" + suffix )
1344
+ table_obj .insert (
1345
+ [{"c1" :"2025-01-16" , "c2" : "1925-01-16 21:44:33" , "c3" :"25-01-16 20:45:11" }])
1346
+
1347
+ res , extra_res = table_obj .output (["century(c1)" , "century(c2)" , "century(c3)" ]).to_pl ()
1348
+ print (res )
1349
+ assert res ['century(c1)' ][0 ] == 21 , "The value of century(c1) should be 21"
1350
+ assert res ['century(c2)' ][0 ] == 20 , "The value of century(c2) should be 20"
1351
+ assert res ['century(c3)' ][0 ] == 1 , "The value of century(c3) should be 1"
1352
+
1353
+ res = db_obj .drop_table ("test_select_century" + suffix )
1354
+ assert res .error_code == ErrorCode .OK
1355
+
1356
+ def test_select_week_of_year (self , suffix ):
1357
+ db_obj = self .infinity_obj .get_database ("default_db" )
1358
+ db_obj .drop_table ("test_select_week_of_year" + suffix , ConflictType .Ignore )
1359
+ db_obj .create_table ("test_select_week_of_year" + suffix ,
1360
+ {"c1" : {"type" : "date" },
1361
+ "c2" : {"type" : "datetime" },
1362
+ "c3" : {"type" : "timestamp" }}, ConflictType .Error )
1363
+ table_obj = db_obj .get_table ("test_select_week_of_year" + suffix )
1364
+ table_obj .insert (
1365
+ [{"c1" :"2025-01-16" , "c2" : "2025-01-01 21:44:33" , "c3" :"2017-12-16 20:45:11" }])
1366
+
1367
+ res , extra_res = table_obj .output (["weekofyear(c1)" , "weekofyear(c2)" , "weekofyear(c3)" ]).to_pl ()
1368
+ print (res )
1369
+ assert res ['weekofyear(c1)' ][0 ] == 3 , "The value of weekofyear(c1) should be 3"
1370
+ assert res ['weekofyear(c2)' ][0 ] == 1 , "The value of weekofyear(c2) should be 1"
1371
+ assert res ['weekofyear(c3)' ][0 ] == 50 , "The value of weekofyear(c3) should be 50"
1372
+
1373
+ res = db_obj .drop_table ("test_select_week_of_year" + suffix )
1374
+ assert res .error_code == ErrorCode .OK
1375
+
1376
+ def test_select_date_part (self , suffix ):
1377
+ db_obj = self .infinity_obj .get_database ("default_db" )
1378
+ db_obj .drop_table ("test_select_date_part" + suffix , ConflictType .Ignore )
1379
+ db_obj .create_table ("test_select_date_part" + suffix ,
1380
+ {"c1" : {"type" : "date" },
1381
+ "c2" : {"type" : "datetime" },
1382
+ "c3" : {"type" : "timestamp" },
1383
+ "c4" : {"type" : "varchar" , "constraints" : ["primary key" , "not null" ]},
1384
+ "c5" : {"type" : "varchar" , "constraints" : ["not null" ]}}, ConflictType .Error )
1385
+ table_obj = db_obj .get_table ("test_select_date_part" + suffix )
1386
+ table_obj .insert (
1387
+ [{"c1" :"2025-01-16" , "c2" : "2025-01-16 21:44:33" , "c3" :"2025-01-16 20:45:11" , "c4" :"year" , "c5" :"month" }])
1388
+
1389
+ res , extra_res = table_obj .output (["datepart(c4, c1)" , "datepart(c4, c2)" , "datepart(c5, c3)" ]).to_pl ()
1390
+ print (res )
1391
+ assert res ['(c4 datepart c1)' ][0 ] == 2025 , "The value of c4 datepart c1 should be 2025"
1392
+ assert res ['(c4 datepart c2)' ][0 ] == 2025 , "The value of c4 datepart c2 should be 2025"
1393
+ assert res ['(c5 datepart c3)' ][0 ] == 1 , "The value of c5 datepart c3 should be 1"
1394
+
1395
+ res = db_obj .drop_table ("test_select_date_part" + suffix )
1396
+ assert res .error_code == ErrorCode .OK
0 commit comments