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

Incorrect query result for trailing duplicate GROUP BY expression

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.12.0
    • 4.14.0, 5.0.0
    • None
    • None
    • minicluster

    Description

      From sme-hbase hipchat room:
      Pulkit Bhardwaj·10:31

      i'm seeing a weird issue with phoenix, appreciate some thoughts

      Created a simple table in phoenix

      0: jdbc:phoenix:> create table test_select(nam VARCHAR(20), address VARCHAR(20), id BIGINT
      . . . . . . . . > constraint my_pk primary key (id));
      
      0: jdbc:phoenix:> upsert into test_select (nam, address,id) values('pulkit','badaun',1);
      
      0: jdbc:phoenix:> select * from test_select;
      +---------+----------+-----+
      |   NAM   | ADDRESS  | ID  |
      +---------+----------+-----+
      | pulkit  | badaun   | 1   |
      +---------+----------+-----+
      
      
      0: jdbc:phoenix:> select distinct 'harshit' as "test_column", nam from test_select;
      +--------------+---------+
      | test_column  |   NAM   |
      +--------------+---------+
      | harshit      | pulkit  |
      +--------------+---------+
      
      
      0: jdbc:phoenix:> select distinct 'harshit' as "test_column", trim(nam), trim(nam) from test_select;
      +--------------+----------------+----------------+
      | test_column  |   TRIM(NAM)    |   TRIM(NAM)    |
      +--------------+----------------+----------------+
      | harshit      | pulkitpulkit  | pulkitpulkit  |
      +--------------+----------------+----------------+
      

      When I apply a trim on the nam column and use it multiple times, the output has the cell data duplicated!

      0: jdbc:phoenix:> select distinct 'harshit' as "test_column", trim(nam), trim(nam), trim(nam) from test_select;
      +--------------+-----------------------+-----------------------+-----------------------+
      | test_column  |       TRIM(NAM)       |       TRIM(NAM)       |       TRIM(NAM)       |
      +--------------+-----------------------+-----------------------+-----------------------+
      | harshit      | pulkitpulkitpulkit  | pulkitpulkitpulkit  | pulkitpulkitpulkit  |
      +--------------+-----------------------+-----------------------+-----------------------+
      

      Wondering if someone has seen this before??

      One thing to note is, if I remove the —— distinct 'harshit' as "test_column" ——  The issue is not seen

      0: jdbc:phoenix:> select trim(nam), trim(nam), trim(nam) from test_select;
      +------------+------------+------------+
      | TRIM(NAM)  | TRIM(NAM)  | TRIM(NAM)  |
      +------------+------------+------------+
      | pulkit     | pulkit     | pulkit     |
      +------------+------------+------------+
      

      Attachments

        1. PHOENIX-4139.patch
          2 kB
          Csaba Skrabak
        2. PHOENIX-4139_v3.patch
          3 kB
          Csaba Skrabak
        3. PHOENIX-4139_v2.patch
          3 kB
          Csaba Skrabak

        Issue Links

          Activity

            People

              cskrabak Csaba Skrabak
              cskrabak Csaba Skrabak
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: