[
https://issues.apache.org/jira/browse/PHOENIX-1258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14139127#comment-14139127
]
Gabriel Reid commented on PHOENIX-1258:
---------------------------------------
[~jaywong] about the naming of the test, it's true that other functions may
have issues when used within GROUP BY statements. However, the underlying
proper (incorrect deserialization) is also an issue when using a function in
other contexts where it has to be deserialized server-side. For example, try
adding the following test without your patch enabled:
{code}
@Test
public void testFilterWithRegexSubstr() throws SQLException {
Connection conn = DriverManager.getConnection(getUrl());
ResultSet rs = conn.createStatement().executeQuery(
"select id from gbt where REGEXP_SUBSTR(uri, '[^\\\\?]+') =
'Report1'");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertTrue(rs.next());
assertEquals(2, rs.getInt(1));
assertFalse(rs.next());
}
{code}
This test should pass, but it will only pass once the patch in
RegexpSubstrFunction is applied. I believe there are other situations like this
(e.g. joins) which can also have a similar issue. This is why I mean that the
test case should be specific to RegexpSubstrFunction, because the test that
you've added is specifically testing the correct deserialization of the
function (by using it in a grouping statement).
A couple of other things to consider:
* now that the test is based off of BaseHBaseManagedTimeIT, there's no need to
do anything with timestamps in the test setup or connections, you can just call
{{DriverManager.getConnection(getUrl())}}, and just create the needed table for
your test at the start of the test.
* {{testScanWithRegexpSubstr()}} is creating a new instance of
{{GroupByWithFunctionIT}}, but this should be necessary, because
{{testScanWithRegexpSubstr()}} is itself an instance method of
{{GroupByWithFunctionIT}}
* the calls to {{assertEquals}} should have the expected value as the first
argument, and the value returned from the ResultSet as the second argument. The
formatting of assertion failure messages is based on this ordering.
> 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,
> regex_substr_func_group2.patch, regex_substr_func_group3.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)