ashishjayamohan commented on code in PR #14385:
URL: https://github.com/apache/pinot/pull/14385#discussion_r1836000919


##########
pinot-core/src/test/java/org/apache/pinot/core/query/optimizer/filter/TimePredicateFilterOptimizerTest.java:
##########
@@ -121,38 +114,74 @@ public void testEpochToEpochDateTimeConvert() {
         new Range(1620833400L, true, null, false));
     testTimeConvert("dateTimeConvert(col, '1:MINUTES:EPOCH', '1:HOURS:EPOCH', 
'30:MINUTES') < 450255",
         new Range(null, false, 27015300L, false));
-    testTimeConvert("dateTimeConvert(col, '1:DAYS:EPOCH', '1:DAYS:EPOCH', 
'30:MINUTES') BETWEEN 18759 AND 18760",
+    testTimeConvert("dateTimeConvert(col, '1:DAYS:EPOCH', '1:DAYS:EPOCH', 
'30:MINUTES') "
+            + "BETWEEN 18759 AND 18760",
         new Range(18759L, true, 18761L, false));
     testTimeConvert("dateTimeConvert(col, '1:DAYS:EPOCH', '1:DAYS:EPOCH', 
'30:MINUTES') = 18759",
         new Range(18759L, true, 18760L, false));
 
     // Invalid time
-    testInvalidTimeConvert("dateTimeConvert(col, '1:SECONDS:EPOCH', 
'1:MINUTES:EPOCH', '30:MINUTES') > 27013846.5");
-    testInvalidTimeConvert("dateTimeConvert(col, '1:SECONDS:EPOCH', 
'30:MINUTES:EPOCH', '30:MINUTES') > 27013846");
+    testInvalidFilterOptimizer("dateTimeConvert(col, '1:SECONDS:EPOCH', 
'1:MINUTES:EPOCH', '30:MINUTES') > 27013846.5");
+    testInvalidFilterOptimizer("dateTimeConvert(col, '1:SECONDS:EPOCH', 
'30:MINUTES:EPOCH', '30:MINUTES') > 27013846");
   }
 
   @Test
   public void testSDFToEpochDateTimeConvert() {
-    testTimeConvert(
-        "dateTimeConvert(col, '1:MILLISECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd 
HH:mm:ss.SSS', '1:MILLISECONDS:EPOCH', "
-            + "'30:MINUTES') > 1620830760000", new Range("2021-05-12 
15:00:00.000", true, null, false));
-    testTimeConvert("dateTimeConvert(col, 
'1:SECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm:ss', '1:MILLISECONDS:EPOCH', "
-        + "'30:MINUTES') < 1620917160000", new Range(null, false, "2021-05-13 
15:00:00", false));
-    testTimeConvert(
-        "dateTimeConvert(col, '1:MINUTES:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm', 
'1:MILLISECONDS:EPOCH', '30:MINUTES') "
-            + "BETWEEN 1620830760000 AND 1620917160000",
-        new Range("2021-05-12 15:00", true, "2021-05-13 15:00", false));
-    testTimeConvert(
-        "dateTimeConvert(col, '1:DAYS:SIMPLE_DATE_FORMAT:yyyy-MM-dd', 
'1:MILLISECONDS:EPOCH', '30:MINUTES') = "
-            + "1620830760000", new Range("2021-05-12", false, "2021-05-12", 
true));
+    testTimeConvert("dateTimeConvert(col, 
'1:MILLISECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm:ss.SSS', '1:MILLISECONDS:"
+        + "EPOCH', '30:MINUTES') > 1620830760000", new Range("2021-05-12 
15:00:00.000", true, null, false));
+    testTimeConvert("dateTimeConvert(col, 
'1:SECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm:ss', '1:MILLISECONDS:EPOCH',"
+        + " '30:MINUTES') < 1620917160000", new Range(null, false, "2021-05-13 
15:00:00", false));
+    testTimeConvert("dateTimeConvert(col, 
'1:MINUTES:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm', '1:MILLISECONDS:EPOCH', "
+        + "'30:MINUTES') BETWEEN 1620830760000 AND 1620917160000", new 
Range("2021-05-12 15:00", true, "2021-05-13 "
+        + "15:00", false));
+    testTimeConvert("dateTimeConvert(col, 
'1:DAYS:SIMPLE_DATE_FORMAT:yyyy-MM-dd', '1:MILLISECONDS:EPOCH', '30:MINUTES')"
+        + " = 1620830760000", new Range("2021-05-12", false, "2021-05-12", 
true));
 
     // Invalid time
-    testInvalidTimeConvert(
-        "dateTimeConvert(col, '1:MILLISECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd 
HH:mm:ss.SSS', '1:MILLISECONDS:EPOCH', "
-            + "'30:MINUTES') > 1620830760000.5");
-    testInvalidTimeConvert(
-        "dateTimeConvert(col, '1:SECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd 
HH:mm:ss', '1:MILLISECONDS:EPOCH', "
-            + "'30:MINUTES') < 1620917160");
+    testInvalidFilterOptimizer("dateTimeConvert(col, 
'1:MILLISECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm:ss.SSS', "
+        + "'1:MILLISECONDS:EPOCH', '30:MINUTES') > 1620830760000.5");
+    testInvalidFilterOptimizer("dateTimeConvert(col, 
'1:SECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm:ss', "
+        + "'1:MILLISECONDS:EPOCH', '30:MINUTES') < 1620917160");
+  }
+
+
+  @Test
+  public void testDateTruncOptimizer() {
+    testDateTrunc("datetrunc('DAY', col) < 1620777600000", new Range("0", 
true, "1620777600000", false));

Review Comment:
   Hey @jadami10. Thanks for this insight! I've been working on this for the 
past couple days (specifically on the time zone test). I've introduced several 
time zone tests and my implementation seems to work only for some time zone 
usages.
   If you're willing, would you be able to write up a quick draft of what the 
algorithm should look like to convert the date_trunc function with time zones 
to a range query (essentially, the floor and ceiling inverse of date trunc). I 
think it would be beneficial to hear it from another perspective to find what 
I'm missing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to