@@ -303,7 +303,7 @@ void testTimeRangeResolverWithOutEndTimeInFilter() {
303303 new PrometheusMetricTable (client , "prometheus_http_total_requests" );
304304
305305
306- //Both endTime and startTime are set.
306+ //Only endTime is set.
307307 List <NamedExpression > finalProjectList = new ArrayList <>();
308308 finalProjectList .add (DSL .named (VALUE , DSL .ref (VALUE , STRING )));
309309 finalProjectList .add (DSL .named (TIMESTAMP , DSL .ref (TIMESTAMP , ExprCoreType .TIMESTAMP )));
@@ -724,6 +724,35 @@ void testImplementWithRelationAndFilter() {
724724 assertEquals (List .of (VALUE , TIMESTAMP ), outputFields );
725725 }
726726
727+ @ Test
728+ void testImplementWithRelationAndTimestampFilter () {
729+ List <NamedExpression > finalProjectList = new ArrayList <>();
730+ finalProjectList .add (DSL .named (VALUE , DSL .ref (VALUE , STRING )));
731+ finalProjectList .add (DSL .named (TIMESTAMP , DSL .ref (TIMESTAMP , ExprCoreType .TIMESTAMP )));
732+ DateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss" );
733+ Long endTime = new Date (System .currentTimeMillis ()).getTime ();
734+ PrometheusMetricTable prometheusMetricTable =
735+ new PrometheusMetricTable (client , "prometheus_http_total_requests" );
736+ LogicalPlan logicalPlan = project (indexScan ("prometheus_http_total_requests" ,
737+ DSL .lte (DSL .ref ("@timestamp" , ExprCoreType .TIMESTAMP ),
738+ DSL .literal (
739+ fromObjectValue (dateFormat .format (new Date (endTime )),
740+ ExprCoreType .TIMESTAMP )))
741+ ), finalProjectList , null );
742+ PhysicalPlan physicalPlan = prometheusMetricTable .implement (logicalPlan );
743+ assertTrue (physicalPlan instanceof ProjectOperator );
744+ assertTrue (((ProjectOperator ) physicalPlan ).getInput () instanceof PrometheusMetricScan );
745+ PrometheusQueryRequest request
746+ = ((PrometheusMetricScan ) ((ProjectOperator ) physicalPlan ).getInput ()).getRequest ();
747+ assertEquals ((3600 / 250 ) + "s" , request .getStep ());
748+ assertEquals ("prometheus_http_total_requests" ,
749+ request .getPromQl ());
750+ List <NamedExpression > projectList = ((ProjectOperator ) physicalPlan ).getProjectList ();
751+ List <String > outputFields
752+ = projectList .stream ().map (NamedExpression ::getName ).collect (Collectors .toList ());
753+ assertEquals (List .of (VALUE , TIMESTAMP ), outputFields );
754+ }
755+
727756 @ Test
728757 void testOptimize () {
729758 PrometheusQueryRequest prometheusQueryRequest = new PrometheusQueryRequest ();
0 commit comments