Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-3756

Order By clause specified in STRING_AGG function is skipped when pushed down to PostgreSQL

    XMLWordPrintable

Details

    Description

      I defined a small table in PostgreSQL as follows:

      create table test_string_agg (col1 varchar(10))
      
      insert into test_string_agg VALUES ('b');
      insert into test_string_agg VALUES ('a');
      insert into test_string_agg VALUES ('c');
      

      When I run a query with a STRING_AGG function where an ORDER BY clause is specified, the strings are not concatenated in the expected order. For example, these three queries:

      select string_agg(col1, ' , ' order by col1) from pg.test_string_agg;
      select string_agg(col1, ' , ' order by col1 desc) from pg.test_string_agg;
      select string_agg(col1, ' , ' order by col1 asc) from pg.test_string_agg;
      

      return all the same result "b , a , c".

      It seems that the ORDER BY clause is not pushed down to PostgreSQL, in fact all the three rewritten queries executed in PostgreSQL look like:

      SELECT STRING_AGG(g_0."col1", ' , ') FROM "public"."test_string_agg" AS g_0	
      

      If the STRING_AGG function is not pushed down (e.g. in MySQL), I get an expected result.

      Attachments

        Activity

          People

            rhn-engineering-shawkins Steven Hawkins
            redfox999 Salvatore R.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: