richardstartin commented on a change in pull request #7861:
URL: https://github.com/apache/pinot/pull/7861#discussion_r761939432



##########
File path: 
pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java
##########
@@ -2387,4 +2387,48 @@ private void testSupportedDistinctQuery(String query) {
     PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query);
     Assert.assertNotNull(pinotQuery);
   }
+
+  @Test
+  public void testQueryWithSemicolon() {
+    String sql;
+    PinotQuery pinotQuery;
+    sql = "SELECT col1, col2 FROM foo;";
+    pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
+    Assert.assertEquals(pinotQuery.getSelectListSize(), 2);
+    
Assert.assertEquals(pinotQuery.getSelectList().get(0).getIdentifier().getName(),
 "col1");
+    
Assert.assertEquals(pinotQuery.getSelectList().get(1).getIdentifier().getName(),
 "col2");
+
+    // Query having extra white spaces before the semicolon
+    sql = "SELECT col1, col2 FROM foo                 ;";
+    pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
+    Assert.assertEquals(pinotQuery.getSelectListSize(), 2);
+    
Assert.assertEquals(pinotQuery.getSelectList().get(0).getIdentifier().getName(),
 "col1");
+    
Assert.assertEquals(pinotQuery.getSelectList().get(1).getIdentifier().getName(),
 "col2");
+
+    sql = "SELECT col1, count(*) FROM foo group by col1;";
+    pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
+    Assert.assertEquals(pinotQuery.getSelectListSize(), 2);
+    
Assert.assertEquals(pinotQuery.getSelectList().get(0).getIdentifier().getName(),
 "col1");
+    Assert.assertEquals(pinotQuery.getGroupByListSize(), 1);
+    
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getIdentifier().getName(),
 "col1");
+    
Assert.assertEquals(pinotQuery.getGroupByList().get(0).getIdentifier().getName(),
 "col1");
+
+    // Check for Option SQL Query
+    sql = "SELECT col1, count(*) FROM foo group by col1 
option(skipUpsert=true);";
+    pinotQuery = CalciteSqlParser.compileToPinotQuery(sql);
+    Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 1);
+    Assert.assertTrue(pinotQuery.getQueryOptions().containsKey("skipUpsert"));

Review comment:
       Can you also add a test case for a literal with a semicolon in it, it 
should pass.
   
   e.g. 
   
   ```
   select col1, count(*) from foo where col1 = 'x;y' option(skipUpsert=true);
   ```




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