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