siddharthteotia commented on code in PR #9017:
URL: https://github.com/apache/pinot/pull/9017#discussion_r919129955


##########
pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java:
##########
@@ -729,6 +731,61 @@ public void testQueryOptions() {
     }
   }
 
+  @Test
+  public void testQuerySetOptions() {
+    PinotQuery pinotQuery =
+        CalciteSqlParser.compileToPinotQuery("select * from vegetables where 
name <> 'Brussels sprouts'");
+    Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 0);
+    Assert.assertNull(pinotQuery.getQueryOptions());
+
+    pinotQuery = CalciteSqlParser.compileToPinotQuery(
+        "SET delicious='yes'; select * from vegetables where name <> 'Brussels 
sprouts'");
+    Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 1);
+    Assert.assertTrue(pinotQuery.getQueryOptions().containsKey("delicious"));
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("delicious"), "yes");
+
+    pinotQuery = CalciteSqlParser.compileToPinotQuery("SET delicious='yes'; 
SET foo='1234'; SET bar='''potato''';"
+        + "select * from vegetables where name <> 'Brussels sprouts' ");
+    Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 3);
+    Assert.assertTrue(pinotQuery.getQueryOptions().containsKey("delicious"));
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("delicious"), "yes");
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("foo"), "1234");
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("bar"), "'potato'");
+
+    pinotQuery = CalciteSqlParser.compileToPinotQuery("SET delicious='yes'; 
SET foo='1234'; "
+        + "SET bar='''potato'''; select * from vegetables where name <> 
'Brussels sprouts' ");
+    Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 3);
+    Assert.assertTrue(pinotQuery.getQueryOptions().containsKey("delicious"));
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("delicious"), "yes");
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("foo"), "1234");
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("bar"), "'potato'");
+
+    pinotQuery = CalciteSqlParser.compileToPinotQuery("SET delicious='yes'; 
SET foo='1234'; "
+        + "select * from vegetables where name <> 'Brussels sprouts'; SET 
bar='''potato'''; ");
+    Assert.assertEquals(pinotQuery.getQueryOptionsSize(), 3);
+    Assert.assertTrue(pinotQuery.getQueryOptions().containsKey("delicious"));
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("delicious"), "yes");
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("foo"), "1234");
+    Assert.assertEquals(pinotQuery.getQueryOptions().get("bar"), "'potato'");
+
+    // test invalid options

Review Comment:
   Can you also add a test where you have 2 DQL statements and 0 or more SET 
statements ?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to