55
66package org .opensearch .sql .calcite .standalone ;
77
8- import static org .opensearch .sql .legacy .TestsConstants .TEST_INDEX_STATE_COUNTRY ;
9- import static org .opensearch .sql .legacy .TestsConstants .TEST_INDEX_STATE_COUNTRY_WITH_NULL ;
10- import static org .opensearch .sql .util .MatcherUtils .rows ;
11- import static org .opensearch .sql .util .MatcherUtils .schema ;
12- import static org .opensearch .sql .util .MatcherUtils .verifyDataRows ;
13- import static org .opensearch .sql .util .MatcherUtils .verifyErrorMessageContains ;
14- import static org .opensearch .sql .util .MatcherUtils .verifyNumOfRows ;
15- import static org .opensearch .sql .util .MatcherUtils .verifySchemaInOrder ;
8+ import static org .opensearch .sql .legacy .TestsConstants .*;
9+ import static org .opensearch .sql .util .MatcherUtils .*;
1610
1711import java .io .IOException ;
1812import java .util .List ;
@@ -28,6 +22,7 @@ public void init() throws IOException {
2822 super .init ();
2923 loadIndex (Index .STATE_COUNTRY );
3024 loadIndex (Index .STATE_COUNTRY_WITH_NULL );
25+ loadIndex (Index .BANK_TWO );
3126 }
3227
3328 @ Test
@@ -600,4 +595,48 @@ public void testEventstatVarianceWithNullBy() {
600595 58.333333333333314 ),
601596 rows ("Hello" , "USA" , "New York" , 4 , 2023 , 30 , 20 , 28.284271247461902 , 400 , 800 ));
602597 }
598+
599+ @ Test
600+ public void testEventstatEarliestAndLatest () {
601+ JSONObject actual =
602+ executeQuery (
603+ String .format (
604+ "source=%s | eventstats earliest(birthdate), latest(birthdate) | head 1" ,
605+ TEST_INDEX_BANK_TWO ));
606+ verifySchema (
607+ actual ,
608+ schema ("account_number" , "long" ),
609+ schema ("firstname" , "string" ),
610+ schema ("address" , "string" ),
611+ schema ("birthdate" , "timestamp" ),
612+ schema ("gender" , "string" ),
613+ schema ("city" , "string" ),
614+ schema ("lastname" , "string" ),
615+ schema ("balance" , "long" ),
616+ schema ("employer" , "string" ),
617+ schema ("state" , "string" ),
618+ schema ("age" , "integer" ),
619+ schema ("email" , "string" ),
620+ schema ("male" , "boolean" ),
621+ schema ("earliest(birthdate)" , "timestamp" ),
622+ schema ("latest(birthdate)" , "timestamp" ));
623+ verifyDataRows (
624+ actual ,
625+ rows (
626+ 1 ,
627+ "Amber JOHnny" ,
628+ "880 Holmes Lane" ,
629+ "2017-10-23 00:00:00" ,
630+ "M" ,
631+ "Brogan" ,
632+ "Duke Willmington" ,
633+ 39225 ,
634+ "Pyrami" ,
635+ "IL" ,
636+ 32 ,
637+ "amberduke@pyrami.com" ,
638+ true ,
639+ "1970-01-18 20:22:32" ,
640+ "2018-08-19 00:00:00" ));
641+ }
603642}
0 commit comments