SELECT DB.Address, DB.City, count(*) as Count FROM "Emp"."persons" as DB

GROUP BY DB.Address, DB.City

ORDER BY DB.City

This query is executed for a table in DB2. When I ran the query I get the exception:

java.lang.AssertionError: Assertion failed.

at org.teiid.core.util.Assertion.failed(Assertion.java:73)

at org.teiid.core.util.Assertion.assertTrue(Assertion.java:68)

at org.teiid.core.util.Assertion.assertTrue(Assertion.java:60)

at org.teiid.query.processor.relational.SortUtility.<init>(SortUtility.java:145)

......

I debugged Teiid. To do sorting, Teiid is checking if the column name to be sorted is existing in the set of columns in the query. For some reason, it is not finding the column name in the list of columns.

Below was the list of columns Teiid found in the query:

[DB.Address As Address, DB.City As City, count(*) as Count]

Teiid was looking for the column ‘anon_grp0.gcol0 AS City’. It could not find this column in the above list and it threw Assertion error.

I was able to reproduce this. It is occurring if the grouping is pushed, but the order by is not. It does not occur if neither or both are pushed. Can you convert this to a JIRA and I'll provide a fix for 7.7 Final?