Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-1458

group_concat does not obey ORDER BY

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Not A Bug
    • Impala 1.4.1
    • None
    • None
    • None

    Description

      I have the impression that `group_concat` should follow the order of the rows it is aggregating. The documentation[1] does not specify that, but there is a test[2] which states "Use a subquery with an ORDER BY to ensure `group_concat` results are in a deterministic order".

      [1] http://www.cloudera.com/content/cloudera/en/documentation/cloudera-impala/v1/latest/Installing-and-Using-Impala/ciiu_group_concat.html

      [2] https://github.com/cloudera/Impala/blob/2dd31f698d4a18db9e99d4ce20da2bbc22ef748b/testdata/workloads/functional-query/queries/QueryTest/aggregation.test#L817

      So, when I run the code below[3], I expect to get the result `a, b, c`.

      Instead, I get `b, a, c`, which suggests the ORDER BY is having no effect.

      Is this a problem with (1) my understanding of how to induce an order, (2) my and the test's expectations – `group_concat` was actually never intended to obey order, or (3) the behavior of `group_concat`?

      [3]

      select group_concat(name) 
      from (
        select * from (
          select 'b' as name
          union all
          select 'a' as name
          union all
          select 'c' as name
        ) names
        order by name
      ) names
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            aaronharnly_impala_157f Aaron Harnly
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: