siddharthteotia commented on a change in pull request #6820:
URL: https://github.com/apache/incubator-pinot/pull/6820#discussion_r636268275



##########
File path: 
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/OfflineClusterIntegrationTest.java
##########
@@ -353,38 +354,52 @@ public void testTimeFunc()
   @Test
   public void testLiteralOnlyFunc()
       throws Exception {
+    long ONE_HOUR_IN_MS = TimeUnit.HOURS.toMillis(1);
     long currentTsMin = System.currentTimeMillis();
-    String sqlQuery = "SELECT 1, now() as currentTs, 'abc', toDateTime(now(), 
'yyyy-MM-dd z') as today, now()";
+    long oneHourAgoTsMin = currentTsMin - ONE_HOUR_IN_MS;
+    String sqlQuery = "SELECT 1, now() as currentTs, ago('PT1H') as 
oneHourAgoTs, 'abc', toDateTime(now(), 'yyyy-MM-dd z') as today, now(), 
ago('PT1H')";
     JsonNode response = postSqlQuery(sqlQuery, _brokerBaseApiUrl);
     long currentTsMax = System.currentTimeMillis();
+    long oneHourAgoTsMax = currentTsMax - ONE_HOUR_IN_MS;
 
     
assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(0).asText(),
 "1");
     
assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(1).asText(),
 "currentTs");
-    
assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(2).asText(),
 "abc");
-    
assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(3).asText(),
 "today");
-    String nowColumnName = 
response.get("resultTable").get("dataSchema").get("columnNames").get(4).asText();
+    
assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(2).asText(),
 "oneHourAgoTs");
+    
assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(3).asText(),
 "abc");
+    
assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(4).asText(),
 "today");
+    String nowColumnName = 
response.get("resultTable").get("dataSchema").get("columnNames").get(5).asText();
+    String oneHourAgoColumnName = 
response.get("resultTable").get("dataSchema").get("columnNames").get(6).asText();
     assertTrue(Long.parseLong(nowColumnName) > currentTsMin);
     assertTrue(Long.parseLong(nowColumnName) < currentTsMax);
+    assertTrue(Long.parseLong(oneHourAgoColumnName) > oneHourAgoTsMin);
+    assertTrue(Long.parseLong(oneHourAgoColumnName) < oneHourAgoTsMax);
 
     
assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(0).asText(),
 "LONG");
     
assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(1).asText(),
 "LONG");
-    
assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(2).asText(),
 "STRING");
+    
assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(2).asText(),
 "LONG");
     
assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(3).asText(),
 "STRING");
-    
assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(4).asText(),
 "LONG");
+    
assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(4).asText(),
 "STRING");
+    
assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(5).asText(),
 "LONG");
+    
assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(6).asText(),
 "LONG");
 
     int first = response.get("resultTable").get("rows").get(0).get(0).asInt();
     long second = 
response.get("resultTable").get("rows").get(0).get(1).asLong();
-    String third = 
response.get("resultTable").get("rows").get(0).get(2).asText();
+    long third = 
response.get("resultTable").get("rows").get(0).get(2).asLong();
+    String fourth = 
response.get("resultTable").get("rows").get(0).get(3).asText();
     assertEquals(first, 1);
     assertTrue(second > currentTsMin);
     assertTrue(second < currentTsMax);
-    assertEquals(third, "abc");
-    String todayStr = 
response.get("resultTable").get("rows").get(0).get(3).asText();
+    assertTrue(third > oneHourAgoTsMin);
+    assertTrue(third < oneHourAgoTsMax);

Review comment:
       I think we should also add a test where ago() is used in comparison in 
the filter clause




-- 
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.

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