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

Gabriel Reid commented on PHOENIX-1258:
---------------------------------------

>From what I learned from [~jamestaylor] on this yesterday, the following 
>addition to RegexpSubstrFunction seems to be the correct way to fix this:
{code}
    @Override
    public void readFields(DataInput input) throws IOException {
        super.readFields(input);
        init();
    }
{code}

The issue is that when being used in a GROUP BY or WHERE clause, the function 
needs to be serialized on the client side and then deserialized on the server 
side. The execution of the init() method within readFields is needed to 
complete the deserialization on the server side.

It might be better to change the GroupByWithFunctionIT class to be called 
RegexpSubstrFunctionIT, as it's testing an issue that is specific to 
RegexpSubstrFunctionIT. Other functions may have the same issue, but this is 
more of a general base serialization functionality that is required by function 
implementations, and not strictly related to GROUP BY expressions.

> RegexpSubstrFunction is not useable with group by query 
> --------------------------------------------------------
>
>                 Key: PHOENIX-1258
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1258
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 3.1
>            Reporter: jay wong
>            Assignee: jay wong
>             Fix For: 3.1
>
>         Attachments: regex_substr_func_group.patch
>
>
> 0: jdbc:phoenix:10.232.98.99:/hbase-phoenix-l> select gmt subgmt from 
> test_salt1 limit 2;
> |   SUBGMT   |
> | asdfasf?fas |
> | basdfasf?fas |
> 2 rows selected (0.071 seconds)
> 0: jdbc:phoenix:10.232.98.99:/hbase-phoenix-l> select REGEXP_SUBSTR(gmt, 
> '[^\\?]+') subgmt from test_salt1 limit 2;
> |   SUBGMT   |
> | asdfasf    |
> | basdfasf   |
> 2 rows selected (0.07 seconds)
> 0: jdbc:phoenix:10.232.98.99:/hbase-phoenix-l> select REGEXP_SUBSTR(gmt, 
> '[^\\?]+') subgmt,sum(int_A) from test_salt1 group by subgmt;
> |   SUBGMT   | SUM(A.INT_A) |
> | null       | 17498        |
> 1 row selected (0.082 seconds)
> the group by result is not expected
> below result is expected
> |SUBGMT       |SUM(A.INT_A)|
> | asdfasf    |   8342 |
> | basdfasf   | 5449 |



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

Reply via email to