stoty commented on code in PR #2098:
URL: https://github.com/apache/phoenix/pull/2098#discussion_r2014275999


##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java:
##########
@@ -234,6 +235,43 @@ public void testSelectFromIndexWithAdditionalWhereClause() 
throws Exception {
         testExtraWhere(conn, tableName);
     }
 
+    @Test
+    public void 
testSelectFromIndexWithWhereClauseButTheValueIsSurroundedByDoubleQuotes() 
throws Exception {
+        String tableName = schemaName + "." + generateUniqueName();
+        String indexName = "IDX_" + generateUniqueName();
+        String indexTableName = schemaName + "." + indexName;
+        Connection conn1 = getConnection();
+        try {
+            if (isNamespaceMapped) {
+                conn1.createStatement().execute("CREATE SCHEMA IF NOT EXISTS " 
+ schemaName);
+            }
+            String ddl = "CREATE TABLE " + tableName + " (t_id VARCHAR NOT 
NULL,\n" +
+                    "k1 INTEGER NOT NULL,\n" +
+                    "k2 INTEGER NOT NULL,\n" +
+                    "k3 INTEGER,\n" +
+                    "v1 VARCHAR,\n" +
+                    "CONSTRAINT pk PRIMARY KEY (t_id, k1, k2))\n";
+            conn1.createStatement().execute(ddl);
+            conn1.createStatement().execute("UPSERT INTO " + tableName + " 
values('b',1,2,4,'z')");
+            conn1.createStatement().execute("UPSERT INTO " + tableName + " 
values('f',1,2,3,'a')");
+            conn1.createStatement().execute("UPSERT INTO " + tableName + " 
values('j',2,4,2,'a')");
+            conn1.createStatement().execute("UPSERT INTO " + tableName + " 
values('q',3,1,1,'c')");
+            conn1.commit();
+            conn1.createStatement().execute("CREATE LOCAL INDEX " + indexName 
+ " ON " + tableName + "(V1)");
+            conn1.commit();
+            //            assertEquals(PIndexState.ACTIVE, 
TestUtil.getIndexState(conn1, indexTableName));
+            assertEquals(4, TestUtil.getRowCount(conn1, indexTableName));
+            ResultSet rs = conn1.createStatement()
+                    .executeQuery("SELECT * FROM " + indexTableName + " WHERE 
\":T_ID\" = \"f\"");
+            assertTrue(rs.next());
+            fail();
+        } catch (SQLException e) { // Expected
+            
assertEquals(SQLExceptionCode.COLUMN_NOT_FOUND.getErrorCode(),e.getErrorCode());
+        } finally {
+            conn1.close();

Review Comment:
   nit: use try-with-resources instead



##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java:
##########
@@ -234,6 +235,43 @@ public void testSelectFromIndexWithAdditionalWhereClause() 
throws Exception {
         testExtraWhere(conn, tableName);
     }
 
+    @Test
+    public void 
testSelectFromIndexWithWhereClauseButTheValueIsSurroundedByDoubleQuotes() 
throws Exception {
+        String tableName = schemaName + "." + generateUniqueName();
+        String indexName = "IDX_" + generateUniqueName();
+        String indexTableName = schemaName + "." + indexName;
+        Connection conn1 = getConnection();
+        try {
+            if (isNamespaceMapped) {
+                conn1.createStatement().execute("CREATE SCHEMA IF NOT EXISTS " 
+ schemaName);
+            }
+            String ddl = "CREATE TABLE " + tableName + " (t_id VARCHAR NOT 
NULL,\n" +
+                    "k1 INTEGER NOT NULL,\n" +
+                    "k2 INTEGER NOT NULL,\n" +
+                    "k3 INTEGER,\n" +
+                    "v1 VARCHAR,\n" +
+                    "CONSTRAINT pk PRIMARY KEY (t_id, k1, k2))\n";
+            conn1.createStatement().execute(ddl);
+            conn1.createStatement().execute("UPSERT INTO " + tableName + " 
values('b',1,2,4,'z')");
+            conn1.createStatement().execute("UPSERT INTO " + tableName + " 
values('f',1,2,3,'a')");
+            conn1.createStatement().execute("UPSERT INTO " + tableName + " 
values('j',2,4,2,'a')");
+            conn1.createStatement().execute("UPSERT INTO " + tableName + " 
values('q',3,1,1,'c')");
+            conn1.commit();
+            conn1.createStatement().execute("CREATE LOCAL INDEX " + indexName 
+ " ON " + tableName + "(V1)");
+            conn1.commit();
+            //            assertEquals(PIndexState.ACTIVE, 
TestUtil.getIndexState(conn1, indexTableName));
+            assertEquals(4, TestUtil.getRowCount(conn1, indexTableName));
+            ResultSet rs = conn1.createStatement()
+                    .executeQuery("SELECT * FROM " + indexTableName + " WHERE 
\":T_ID\" = \"f\"");
+            assertTrue(rs.next());
+            fail();
+        } catch (SQLException e) { // Expected
+            
assertEquals(SQLExceptionCode.COLUMN_NOT_FOUND.getErrorCode(),e.getErrorCode());

Review Comment:
   Can you also check the column name ?



##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java:
##########
@@ -234,6 +235,43 @@ public void testSelectFromIndexWithAdditionalWhereClause() 
throws Exception {
         testExtraWhere(conn, tableName);
     }
 
+    @Test
+    public void 
testSelectFromIndexWithWhereClauseButTheValueIsSurroundedByDoubleQuotes() 
throws Exception {
+        String tableName = schemaName + "." + generateUniqueName();
+        String indexName = "IDX_" + generateUniqueName();
+        String indexTableName = schemaName + "." + indexName;
+        Connection conn1 = getConnection();
+        try {
+            if (isNamespaceMapped) {
+                conn1.createStatement().execute("CREATE SCHEMA IF NOT EXISTS " 
+ schemaName);
+            }
+            String ddl = "CREATE TABLE " + tableName + " (t_id VARCHAR NOT 
NULL,\n" +
+                    "k1 INTEGER NOT NULL,\n" +
+                    "k2 INTEGER NOT NULL,\n" +
+                    "k3 INTEGER,\n" +
+                    "v1 VARCHAR,\n" +
+                    "CONSTRAINT pk PRIMARY KEY (t_id, k1, k2))\n";
+            conn1.createStatement().execute(ddl);
+            conn1.createStatement().execute("UPSERT INTO " + tableName + " 
values('b',1,2,4,'z')");

Review Comment:
   Do we need these upserts ?



-- 
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: issues-unsubscr...@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to