[teiid-issues] [JBoss JIRA] (TEIID-3756) Order By clause specified in STRING_AGG function is skipped when pushed down to PostgreSQL
Salvatore R (JIRA)
issues at jboss.org
Mon Oct 19 09:02:00 EDT 2015
[ https://issues.jboss.org/browse/TEIID-3756?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119435#comment-13119435 ]
Salvatore R commented on TEIID-3756:
------------------------------------
Thanks Steven for fixing this issue.
Even if not strictly related to this issue because it happens only if the STRING_AGG function is not pushed down, I am experiencing a similar problem when DISTINCT and ORDER BY clauses are both specified in the aggregate function.
For example, the following queries:
{code:sql}
SELECT string_agg(DISTINCT col1, ',' ORDER BY col1 DESC) from my.test_string_agg;
SELECT string_agg(DISTINCT col1, ',' ORDER BY col1 ASC) from my.test_string_agg;
{code}
return the same result "a,b,c" if the function is not pushed down and locally processed in Teiid.
> Order By clause specified in STRING_AGG function is skipped when pushed down to PostgreSQL
> ------------------------------------------------------------------------------------------
>
> Key: TEIID-3756
> URL: https://issues.jboss.org/browse/TEIID-3756
> Project: Teiid
> Issue Type: Bug
> Components: Query Engine
> Affects Versions: 8.4
> Reporter: Salvatore R
> Assignee: Steven Hawkins
> Fix For: 8.12, 8.11.5
>
>
> I defined a small table in PostgreSQL as follows:
> {code:sql}
> 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');
> {code}
> 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:
> {code:sql}
> 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;
> {code}
> 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:
> {code:sql}
> SELECT STRING_AGG(g_0."col1", ' , ') FROM "public"."test_string_agg" AS g_0
> {code}
> If the STRING_AGG function is not pushed down (e.g. in MySQL), I get an expected result.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the teiid-issues
mailing list