@@ -580,6 +580,10 @@ TEST_F(ClpConnectorTest, test4IrTimestampNoPushdown) {
580580TEST_F (ClpConnectorTest, test4IrTimestampPushdown) {
581581 // Only the second event meet the condition, the first event is a date string
582582 // which is not supported yet so the value will be NULL.
583+ // This test can not use the `timestamp()` literal, since the integer
584+ // timestamps are in microsecond precision, and we currently assume all IR
585+ // timestamps are millisecond precision when comparing against timestamp
586+ // literals.
583587 const std::shared_ptr<std::string> kqlQuery =
584588 std::make_shared<std::string>(" (timestamp < 1756003005000000)" );
585589 auto plan =
@@ -661,11 +665,9 @@ TEST_F(ClpConnectorTest, test5FloatTimestampNoPushdown) {
661665
662666TEST_F (ClpConnectorTest, test5FloatTimestampPushdown) {
663667 // Test filtering rows with a timestamp parsed from a date string and floats
664- // in various formats. Because KQL doesn’t automatically interpret the unit of
665- // the timestamp, the returned result differs slightly from the one without
666- // pushdown.
668+ // in various formats.
667669 const std::shared_ptr<std::string> kqlQuery = std::make_shared<std::string>(
668- " (timestamp < 1746003005.127 and timestamp >= 1746003005.124 )" );
670+ R "( timestamp < timestamp("1746003070000", "\L") and timestamp >= timestamp("1746003005124", "\L") )" );
669671 auto plan =
670672 PlanBuilder (pool_.get ())
671673 .startTableScan ()
@@ -695,12 +697,67 @@ TEST_F(ClpConnectorTest, test5FloatTimestampPushdown) {
695697 {Timestamp (1746003005 , 124000000 ),
696698 Timestamp (1746003005 , 124100000 ),
697699 Timestamp (1746003005 , 125000000 ),
698- Timestamp (1746003005 , 126000000 )}),
700+ Timestamp (1746003005 , 126000000 ),
701+ Timestamp (1746003005 , 127000000 ),
702+ Timestamp (1746003060 , 0 ),
703+ Timestamp (1746003065 , 0 )}),
699704 makeFlatVector<double >(
700- {1.234567891234500E9 ,
705+ {1.2345678912345E9 ,
701706 1E16 ,
702707 1.234567891234567E9 ,
703- 1.234567891234567E9 })});
708+ 1.234567891234567E9 ,
709+ -1.234567891234567E-9 ,
710+ 1234567891.234567 ,
711+ -1234567891.234567 })});
712+ test::assertEqualVectors (expected, output);
713+ }
714+
715+ TEST_F (ClpConnectorTest, test5NewTimestampFormatFloatTimestampPushdown) {
716+ // Test filtering rows with a timestamp parsed from a date string and floats
717+ // in various formats.
718+ const std::shared_ptr<std::string> kqlQuery = std::make_shared<std::string>(
719+ R"( timestamp < timestamp("1746003070000", "\L") and timestamp >= timestamp("1746003005124", "\L"))" );
720+ auto plan =
721+ PlanBuilder (pool_.get ())
722+ .startTableScan ()
723+ .outputType (ROW ({" timestamp" , " floatValue" }, {TIMESTAMP (), DOUBLE ()}))
724+ .tableHandle (
725+ std::make_shared<ClpTableHandle>(kClpConnectorId , " test_5" ))
726+ .assignments (
727+ {{" timestamp" ,
728+ std::make_shared<ClpColumnHandle>(
729+ " timestamp" , " timestamp" , TIMESTAMP ())},
730+ {" floatValue" ,
731+ std::make_shared<ClpColumnHandle>(
732+ " floatValue" , " floatValue" , DOUBLE ())}})
733+ .endTableScan ()
734+ .orderBy ({" \" timestamp\" ASC" }, false )
735+ .planNode ();
736+
737+ auto output = getResults (
738+ plan,
739+ {makeClpSplit (
740+ getExampleFilePath (" test_5.v0.5.0.clps" ),
741+ ClpConnectorSplit::SplitType::kArchive ,
742+ kqlQuery)});
743+ auto expected = makeRowVector (
744+ {// timestamp
745+ makeFlatVector<Timestamp>(
746+ {Timestamp (1746003005 , 124000000 ),
747+ Timestamp (1746003005 , 124100000 ),
748+ Timestamp (1746003005 , 125000000 ),
749+ Timestamp (1746003005 , 126000000 ),
750+ Timestamp (1746003005 , 127000001 ),
751+ Timestamp (1746003060 , 0 ),
752+ Timestamp (1746003065 , 0 )}),
753+ makeFlatVector<double >(
754+ {1.2345678912345E9 ,
755+ 1E16 ,
756+ 1.234567891234567E9 ,
757+ 1.234567891234567E9 ,
758+ -1.234567891234567E-9 ,
759+ 1234567891.234567 ,
760+ -1234567891.234567 })});
704761 test::assertEqualVectors (expected, output);
705762}
706763
0 commit comments