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


##########
phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java:
##########
@@ -1026,4 +1029,81 @@ 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 = 13;
+        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";
+
+        containingQueries[3] = "select * from myTableDesc where (ID, B) > 
('i3', 'a') and A >= 10";
+        containedQueries[3] = "select * from myTable where ID = 'i3' and B = 
'c' and A = 10";
+
+        containingQueries[4] = "select * from myTable where ID >= 'i3' and A 
between 5 and 15";
+        containedQueries[4] = "select * from myTableDesc where ID = 'i3' and A 
between 5 and 10";
+
+        containingQueries[5] = "select * from myTable where (A between 5 and 
15) and " +
+                "(D < 10.67 or C <= CURRENT_DATE())";
+        containedQueries[5] = "select * from myTable where (A = 5 and D 
between 1.5 and 9.99) or " +
+                "(A = 6 and C <= CURRENT_DATE() - 1000)";
+
+        containingQueries[6] = "select * from myTable where A is not null";
+        containedQueries[6] = "select * from myTable where A > 0";
+
+        containingQueries[7] = "select * from myTable where NOT (B is null)";
+        containedQueries[7] = "select * from myTable where (B > 'abc')";
+
+        containingQueries[8] = "select * from myTable where A >= E and D <= A";
+        containedQueries[8] = "select * from myTable where (A > E and D = A)";
+
+        containingQueries[9] = "select * from myTable where A > E";
+        containedQueries[9] = "select * from myTable where (A > E  and B is 
not null)";
+
+        containingQueries[10] = "select * from myTable where B like '%abc'";
+        containedQueries[10] = "select * from myTable where (B like '%abc' and 
ID > 'i1')";
+
+        containingQueries[11] = "select * from myTable where " +
+                "PHOENIX_ROW_TIMESTAMP() < CURRENT_TIME()";
+        containedQueries[11] = "select * from myTable where " +
+                "(PHOENIX_ROW_TIMESTAMP() < CURRENT_TIME() - 1)";
+
+        containingQueries[12] = "select * from myTable where (A, E) IN ((2,3), 
(7,8), (10,11))";
+        containedQueries[12] = "select * from myTable where (A, E) IN ((2,3), 
(7,8))";

Review Comment:
   Shouldn't these test queries be passing
   
           containingQueries[13] = "select * from myTable where ID > 'i3' and 
ID < 'i5'";
           containedQueries[13] = "select * from myTable where (ID = 'i4') ";
   



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