tkhurana commented on code in PR #1701:
URL: https://github.com/apache/phoenix/pull/1701#discussion_r1372417042


##########
phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java:
##########
@@ -1026,4 +1029,78 @@ public void testScanCaching_CustomFetchSizeOnStatement() 
throws SQLException {
         assertEquals(FETCH_SIZE, pstmt.getFetchSize());
         assertEquals(FETCH_SIZE, scan.getCaching());
     }
+    private Expression getDNF(PhoenixConnection pconn, String query) throws 
SQLException {
+        //SQLParser parser = new SQLParser("where ID = 'i1' or (ID = 'i2' and 
A > 1)");
+        //        ParseNode where = parser.parseWhereClause()
+        PhoenixPreparedStatement pstmt = newPreparedStatement(pconn, query);
+        QueryPlan plan = pstmt.compileQuery();
+        ParseNode where = plan.getStatement().getWhere();
+
+        return transformDNF(where, plan.getContext());
+    }
+    @Test
+    public void testWhereInclusion() throws SQLException {
+        PhoenixConnection pconn = DriverManager.getConnection(getUrl(),
+                
PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
+        String ddl = "create table myTable(ID varchar primary key, A integer, 
B varchar, " +
+                "C date, D double, E integer)";
+        pconn.createStatement().execute(ddl);
+        ddl = "create table myTableDesc(ID varchar primary key DESC, A 
integer, B varchar, " +
+                "C date, D double, E integer)";
+        pconn.createStatement().execute(ddl);
+
+        final int NUM = 12;
+        String[] containingQueries = new String[NUM];
+        String[] containedQueries = new String[NUM];
+
+        containingQueries[0] = "select * from myTable where ID = 'i1' or (ID = 
'i2' and A > 1)";
+        containedQueries[0] = "select * from myTableDesc where ID = 'i1' or 
(ID = 'i2' and " +
+                "A > 2 + 2)";
+
+        containingQueries[1] = "select * from myTable where ID > 'i3' and A > 
1";
+        containedQueries[1] = "select * from myTableDesc where (ID > 'i7' or 
ID = 'i4') and " +
+                "A > 2 * 10";
+
+        containingQueries[2] = "select * from myTable where ID IN ('i3', 'i7', 
'i1') and A < 10";
+        containedQueries[2] = "select * from myTableDesc where ID IN ('i1', 
'i7') and A < 10 / 2";

Review Comment:
   @kadirozde  can you add a test where the IN list is on a RVC expression



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

Reply via email to