Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-2139

LIKE '%' is not filtering out null columns

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.5.0
    • None
    • None

    Description

      Found based on PhoenixDatabaseMetaData.getColumns() not filtering when column name is null.

      This test should pass:

          @Test
          public void testLikeEverythingExpression() throws Exception {
              Connection conn = DriverManager.getConnection(getUrl());
              String ddl = "CREATE TABLE t (k1 VARCHAR, k2 VARCHAR, CONSTRAINT pk PRIMARY KEY (k1,k2))";
              conn.createStatement().execute(ddl);
              conn.createStatement().execute("UPSERT INTO t VALUES('aa','bb')");
              conn.createStatement().execute("UPSERT INTO t VALUES('ab','bc')");
              conn.createStatement().execute("UPSERT INTO t VALUES(null,'cc')");
              conn.createStatement().execute("UPSERT INTO t VALUES('dd',null)");
              conn.commit();
              
              ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM t WHERE k1 LIKE '%'");
              assertTrue(rs.next());
              assertEquals("aa", rs.getString(1));
              assertEquals("bb", rs.getString(2));
              assertTrue(rs.next());
              assertEquals("ab", rs.getString(1));
              assertEquals("bc", rs.getString(2));
              assertTrue(rs.next());
              assertEquals("dd", rs.getString(1));
              assertEquals(null, rs.getString(2));
              assertFalse(rs.next());
              
              rs = conn.createStatement().executeQuery("SELECT * FROM t WHERE k2 LIKE '%'");
              assertTrue(rs.next());
              assertEquals(null, rs.getString(1));
              assertEquals("cc", rs.getString(2));
              assertTrue(rs.next());
              assertEquals("aa", rs.getString(1));
              assertEquals("bb", rs.getString(2));
              assertTrue(rs.next());
              assertEquals("ab", rs.getString(1));
              assertEquals("bc", rs.getString(2));
              assertFalse(rs.next());
              
              conn.close();
          }
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jamestaylor James R. Taylor
            jamestaylor James R. Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment