[ 
https://issues.apache.org/jira/browse/PHOENIX-1684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14377014#comment-14377014
 ] 

ASF GitHub Bot commented on PHOENIX-1684:
-----------------------------------------

GitHub user twdsilva opened a pull request:

    https://github.com/apache/phoenix/pull/54

    PHOENIX-1684 Functional Index using REGEXP_SUBSTR doesn't work correctly

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/twdsilva/phoenix regex

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/phoenix/pull/54.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #54
    
----
commit fd658f5bfd9e52cbf91346f06470aa38e07a1360
Author: Thomas <[email protected]>
Date:   2015-03-19T20:57:27Z

    init fix

commit 3b7d4258bd97ec8f0b4327d39a2cce68f4c5ec9d
Author: Thomas D'Silva <[email protected]>
Date:   2015-03-19T21:43:03Z

    fix tests

commit 4432e4c3570b1b58da2d2efa9384537d4069a388
Author: Thomas D'Silva <[email protected]>
Date:   2015-03-19T22:13:33Z

    minor

commit a13e203d68d49bd2cab8d4024ef234bf7ca6004a
Author: Thomas D'Silva <[email protected]>
Date:   2015-03-19T22:47:21Z

    fix bugs

commit 59babccf12719930c1fc11ee4b35862626483549
Author: Thomas D'Silva <[email protected]>
Date:   2015-03-20T01:14:43Z

    fix

commit dba021323baa3ff63811241d41e7eae8abf370bb
Author: Thomas D'Silva <[email protected]>
Date:   2015-03-23T17:40:00Z

    final fix

commit 6e51f8354e005b206eb5c72d998ac26bc936141d
Author: Thomas D'Silva <[email protected]>
Date:   2015-03-24T00:46:28Z

    minor refactor

commit 951eac169fb48678a1350f865b7c459aae130e6b
Author: Thomas D'Silva <[email protected]>
Date:   2015-03-24T00:48:11Z

    minor refactor

----


> Functional Index using REGEXP_SUBSTR doesn't work correctly
> -----------------------------------------------------------
>
>                 Key: PHOENIX-1684
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1684
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.0.0, 5.0.0
>            Reporter: Thomas D'Silva
>            Assignee: Thomas D'Silva
>              Labels: 4.3.1
>
> If you create a function index using REGEXP_SUBSTR(column_name,'id:[0-9]+') , 
> the index is not used correctly. This is probably because of the special 
> characters in the regex. 
> {code}
> protected void helpTestFunctionWithArgs(boolean mutable, boolean localIndex) 
> throws Exception {
>               Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
>               Connection conn = DriverManager.getConnection(getUrl(), props);
>               try {
>                       conn.createStatement().execute(
>                                       "CREATE TABLE t (k VARCHAR NOT NULL 
> PRIMARY KEY, v VARCHAR) "
>                                                       + (mutable ? 
> "IMMUTABLE_ROWS=true" : ""));
>                       String query = "SELECT * FROM t";
>                       ResultSet rs = 
> conn.createStatement().executeQuery(query);
>                       assertFalse(rs.next());
>                       String ddl = "CREATE " + (localIndex ? "LOCAL" : "")
>                                       + " INDEX idx ON t 
> (REGEXP_SUBSTR(v,'id:[0-9]+'))";
>                       PreparedStatement stmt = conn.prepareStatement(ddl);
>                       stmt.execute();
>                       query = "SELECT * FROM idx";
>                       rs = conn.createStatement().executeQuery(query);
>                       assertFalse(rs.next());
>                       stmt = conn.prepareStatement("UPSERT INTO t 
> VALUES(?,?)");
>                       stmt.setString(1, "k1");
>                       stmt.setString(2, "v1");
>                       stmt.execute();
>                       stmt.setString(1, "k2");
>                       stmt.setString(2, "v2");
>                       stmt.execute();
>                       conn.commit();
>                       query = "SELECT k FROM t WHERE 
> REGEXP_SUBSTR(v,'id:[0-9]+') = '1'";
>                       rs = conn.createStatement().executeQuery("EXPLAIN " + 
> query);
>                       if (localIndex) {
>                               assertEquals(
>                                               "CLIENT PARALLEL 1-WAY RANGE 
> SCAN OVER IDX ['1']\n"
>                                                               + "    SERVER 
> FILTER BY FIRST KEY ONLY",
>                                               QueryUtil.getExplainPlan(rs));
>                       } else {
>                               assertEquals(
>                                               "CLIENT PARALLEL 1-WAY RANGE 
> SCAN OVER IDX ['1']\n"
>                                                               + "    SERVER 
> FILTER BY FIRST KEY ONLY",
>                                               QueryUtil.getExplainPlan(rs));
>                       }
>                       rs = conn.createStatement().executeQuery(query);
>                       assertTrue(rs.next());
>                       assertEquals("k1", rs.getString(1));
>                       assertFalse(rs.next());
>               } finally {
>                       conn.close();
>               }
>       }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to