@@ -4388,6 +4388,42 @@ public void approxPercentileTest() {
43884388 DATABASE_NAME );
43894389 }
43904390
4391+ @ Test
4392+ public void percentileTest () {
4393+ tableResultSetEqualTest (
4394+ "select percentile(time, 0.5),percentile(s1,0.5),percentile(s2,0.5),percentile(s3,0.5),percentile(s4,0.5),percentile(s9,0.5) from table1" ,
4395+ buildHeaders (6 ),
4396+ new String [] {"2024-09-24T06:15:40.000Z,40,43000,37.5,43.0,2024-09-24T06:15:40.000Z," },
4397+ DATABASE_NAME );
4398+
4399+ tableResultSetEqualTest (
4400+ "select time,province,percentile(time, 0.5),percentile(s1,0.5),percentile(s2,0.5) from table1 group by 1,2 order by 2,1" ,
4401+ new String [] {"time" , "province" , "_col2" , "_col3" , "_col4" },
4402+ new String [] {
4403+ "2024-09-24T06:15:30.000Z,beijing,2024-09-24T06:15:30.000Z,30,null," ,
4404+ "2024-09-24T06:15:31.000Z,beijing,2024-09-24T06:15:31.000Z,null,31000," ,
4405+ "2024-09-24T06:15:35.000Z,beijing,2024-09-24T06:15:35.000Z,null,35000," ,
4406+ "2024-09-24T06:15:36.000Z,beijing,2024-09-24T06:15:36.000Z,36,null," ,
4407+ "2024-09-24T06:15:40.000Z,beijing,2024-09-24T06:15:40.000Z,40,40000," ,
4408+ "2024-09-24T06:15:41.000Z,beijing,2024-09-24T06:15:41.000Z,41,null," ,
4409+ "2024-09-24T06:15:46.000Z,beijing,2024-09-24T06:15:46.000Z,null,46000," ,
4410+ "2024-09-24T06:15:50.000Z,beijing,2024-09-24T06:15:50.000Z,null,50000," ,
4411+ "2024-09-24T06:15:51.000Z,beijing,2024-09-24T06:15:51.000Z,null,null," ,
4412+ "2024-09-24T06:15:55.000Z,beijing,2024-09-24T06:15:55.000Z,55,null," ,
4413+ "2024-09-24T06:15:30.000Z,shanghai,2024-09-24T06:15:30.000Z,30,null," ,
4414+ "2024-09-24T06:15:31.000Z,shanghai,2024-09-24T06:15:31.000Z,null,31000," ,
4415+ "2024-09-24T06:15:35.000Z,shanghai,2024-09-24T06:15:35.000Z,null,35000," ,
4416+ "2024-09-24T06:15:36.000Z,shanghai,2024-09-24T06:15:36.000Z,36,null," ,
4417+ "2024-09-24T06:15:40.000Z,shanghai,2024-09-24T06:15:40.000Z,40,40000," ,
4418+ "2024-09-24T06:15:41.000Z,shanghai,2024-09-24T06:15:41.000Z,41,null," ,
4419+ "2024-09-24T06:15:46.000Z,shanghai,2024-09-24T06:15:46.000Z,null,46000," ,
4420+ "2024-09-24T06:15:50.000Z,shanghai,2024-09-24T06:15:50.000Z,null,50000," ,
4421+ "2024-09-24T06:15:51.000Z,shanghai,2024-09-24T06:15:51.000Z,null,null," ,
4422+ "2024-09-24T06:15:55.000Z,shanghai,2024-09-24T06:15:55.000Z,55,null," ,
4423+ },
4424+ DATABASE_NAME );
4425+ }
4426+
43914427 @ Test
43924428 public void exceptionTest () {
43934429 tableAssertTestFail (
@@ -4478,6 +4514,22 @@ public void exceptionTest() {
44784514 "select 1 as g, approx_percentile(s1,s2,0.5) from table1 group by 1" ,
44794515 "701: Aggregation functions [approx_percentile] do not support weight as INT64 type" ,
44804516 DATABASE_NAME );
4517+ tableAssertTestFail (
4518+ "select percentile() from table1" ,
4519+ "701: Aggregation functions [percentile] should only have two arguments" ,
4520+ DATABASE_NAME );
4521+ tableAssertTestFail (
4522+ "select percentile(s1,1.1) from table1" ,
4523+ "701: percentage should be in [0,1], got 1.1" ,
4524+ DATABASE_NAME );
4525+ tableAssertTestFail (
4526+ "select percentile(s1,'test') from table1" ,
4527+ "701: The second argument of 'percentile' function percentage must be a double literal" ,
4528+ DATABASE_NAME );
4529+ tableAssertTestFail (
4530+ "select percentile(s5,0.5) from table1" ,
4531+ "701: Aggregation functions [percentile] should have value column as numeric type [INT32, INT64, FLOAT, DOUBLE, TIMESTAMP]" ,
4532+ DATABASE_NAME );
44814533 }
44824534
44834535 // ==================================================================
0 commit comments