phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dumindu Buddhika (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (PHOENIX-2205) Group by a divided value (e.g., time/10) returns NULL.
Date Mon, 07 Sep 2015 14:46:46 GMT

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

Dumindu Buddhika edited comment on PHOENIX-2205 at 9/7/15 2:46 PM:
-------------------------------------------------------------------

[~jamestaylor] in this case here at RowKeyColumnExpression,
{code}
if (fromType.isFixedWidth()) {
                Integer maxLength = getMaxLength();
{code}
maxLength come as 38 from the DivisionExpression for the division operation.

Changing the logic from,
{code}
byteSize = maxLength == null ? fromType.getByteSize() : maxLength;
{code}
to
{code}
byteSize = fromType.getByteSize() == null ? maxLength : fromType.getByteSize();
{code}

solves the issue. Is this correct to determine byteSize?


was (Author: dumindux):
[~jamestaylor] int this case here at RowKeyColumnExpression,
{code}
if (fromType.isFixedWidth()) {
                Integer maxLength = getMaxLength();
{code}
maxLength come as 38 from the DivisionExpression for the division operation.

Changing the logic from,
{code}
byteSize = maxLength == null ? fromType.getByteSize() : maxLength;
{code}
to
{code}
byteSize = fromType.getByteSize() == null ? maxLength : fromType.getByteSize();
{code}

solves the issue. Is this correct to determine byteSize?

> Group by a divided value (e.g., time/10) returns NULL.
> ------------------------------------------------------
>
>                 Key: PHOENIX-2205
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2205
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Rafit Izhak Ratzin
>            Assignee: Dumindu Buddhika
>         Attachments: PHOENIX-2205.patch
>
>
> Running with an environment that includes:  phoenix version 4.5.0,  HBase version 0.98,
Cloudera 5.2
> When I group by a divided value (e.g., time/10) the divided value will return as NULL.
> Please see the simple examples below,
> Thanks in advance, 
> --Rafit
>  create table test(time integer not null, hostname varchar not null,usage float constraint
pk PRIMARY KEY(time, hostname));
> upsert into test values(1439853441,'qa8',3.28);
> upsert into test values(1439853449,'qa8',3.28);
> upsert into test values(1439853459,'qa8',3.28);
> upsert into test values(1439853458,'qa8',3.27);
> upsert into test values(1439853457,'qa8',6.27);
> upsert into test values(1439853462,'qa8',8.27);
> upsert into test values(1439853462,'qa9',8.27);
> upsert into test values(1439853457,'qa9',6.27);
> 0: jdbc:phoenix:localhost> select * from test;
> +------------------------------------------+------------------------------------------+----------------------------------------+
> |                   TIME                 |                 HOSTNAME        |        
         USAGE           |
> +------------------------------------------+------------------------------------------+----------------------------------------+
> | 1439853441                         | qa8                                      | 3.28
                                |
> | 1439853449                         | qa8                                      | 3.28
                                |
> | 1439853457                         | qa8                                      | 6.27
                                |
> | 1439853457                         | qa9                                      | 6.27
                                |
> | 1439853458                         | qa8                                      | 3.27
                                |
> | 1439853459                         | qa8                                      | 3.28
                                |
> | 1439853462                         | qa8                                      | 8.27
                                |
> | 1439853462                         | qa9                                      | 8.27
                                |
> +------------------------------------------+------------------------------------------+----------------------------------------+
> 0: jdbc:phoenix:localhost> select time/10, hostname, usage from test;
> +----------------------------------------+------------------------------------------+------------------------------------------+
> |              (TIME / 10)           |                 HOSTNAME        |            
     USAGE              |
> +----------------------------------------+------------------------------------------+------------------------------------------+
> | 143985344                         | qa8                                      | 3.28
                                  |
> | 143985344                         | qa8                                      | 3.28
                                  |
> | 143985345                         | qa8                                      | 6.27
                                  |
> | 143985345                         | qa9                                      | 6.27
                                  |
> | 143985345                         | qa8                                      | 3.27
                                  |
> | 143985345                         | qa8                                      | 3.28
                                  |
> | 143985346                         | qa8                                      | 8.27
                                  |
> | 143985346                         | qa9                                      | 8.27
                                  |
> +----------------------------------------+------------------------------------------+------------------------------------------+
> 0: jdbc:phoenix:localhost> select time/10 as tm, hostname, avg(usage) from test group
by hostname, tm;
> +----------------------------------------+------------------------------------------+------------------------------------------+
> |                   TM                  |                 HOSTNAME        |         
      AVG(USAGE)       |
> +----------------------------------------+------------------------------------------+------------------------------------------+
> | null                                   |                                          |
3.2799                                   |
> | null                                   |                                          |
4.2733                                   |
> | null                                   |                                          |
6.2699                                   |
> | null                                   |                                          |
8.27                                      |
> | null                                   |                                          |
8.27                                      |
> +----------------------------------------+------------------------------------------+------------------------------------------+
> hostname is empty, time/10 is null
> I thought it might be related to the fact that the time is a primary key so I ran the
next test case:
> 0: jdbc:phoenix:localhost> create table test1(time integer not null, hostname varchar
not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname));
> 0: jdbc:phoenix:localhost> upsert into test1 values(1439853462,'qa9',8.27,1439853462);
> 0: jdbc:phoenix:localhost> upsert into test1 values(1439853461,'qa9',8.27,1439853362);
> 0: jdbc:phoenix:localhost> upsert into test1 values(1439853461,'qa9',5.27,1439853461);
> 0: jdbc:phoenix:localhost> upsert into test1 values(1439853451,'qa9',4.27,1439853451);
> 0: jdbc:phoenix:localhost> select * from test1;
> +-------------------------------------+-------------------------------------+--------------------------------------+---------------------------------------+
> |                   TIME            |            HOSTNAME       |              USAGE
             |               PERIOD             |
> +-------------------------------------+-------------------------------------+--------------------------------------+---------------------------------------+
> | 1439853451                    | qa9                                | 4.27         
                      | 1439853451                      |
> | 1439853461                    | qa9                                | 5.27         
                      | 1439853461                      |
> | 1439853462                    | qa9                                | 8.27         
                      | 1439853462                      |
> +-------------------------------------+------------------------------------+--------------------------------------+----------------------------------------+
> 0: jdbc:phoenix:localhost> select period/10 as tm, hostname, usage from test1 ;
> +----------------------------------------+------------------------------------------+------------------------------------------+
> |                   TM                  |                 HOSTNAME        |         
        USAGE             |
> +----------------------------------------+------------------------------------------+------------------------------------------+
> | 143985345                         | qa9                                     | 4.27
                                   |
> | 143985346                         | qa9                                     | 5.27
                                   |
> | 143985346                         | qa9                                     | 8.27
                                   |
> +----------------------------------------+------------------------------------------+------------------------------------------+
> +----------------------------------------+------------------------------------------+------------------------------------------+
> |                   TM                  |                 HOSTNAME        |         
      AVG(USAGE)      |
> +----------------------------------------+------------------------------------------+------------------------------------------+
> | null                                   | qa8                                      |
4.2699                                |
> | null                                   | qa9                                      |
4.2699                                |
> | null                                   | qa9                                      |
6.77                                    |
> +----------------------------------------+------------------------------------------+------------------------------------------+
> Now we can see the hostname (it is not an empty field as before) but tm is still null.



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

Mime
View raw message