[teiid-issues] [JBoss JIRA] (TEIID-1991) GROUP BY pushdown into subselect of UNIONs
Mark Addleman (JIRA)
jira-events at lists.jboss.org
Wed Apr 4 13:51:47 EDT 2012
[ https://issues.jboss.org/browse/TEIID-1991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12681810#comment-12681810 ]
Mark Addleman commented on TEIID-1991:
--------------------------------------
Actually, it is not contrived. Our use case is a union of named extracts of data (we call these data marts). This is the moral equivalent of Teiid's multi-source model. The constant column indicates the data mart name. We create a view for each of these unions. The goal is to get a distinct list of data mart names by querying the view.
It seems to me that the following query
SELECT t.a FROM (
SELECT 'dm1' AS a, dm1.b FROM dm1
UNION
SELECT 'dm2' AS a, dm2.b FROM ds2
) t GROUP BY a
can be rewritten as
SELECT t.a FROM (
SELECT 'dm1' AS a FROM (SELECT 1 FROM dm1.b) t
UNION
SELECT 'dm2' AS a FROM (SELECT 1 FROM dm2.b) t
) t GROUP BY a
> GROUP BY pushdown into subselect of UNIONs
> ------------------------------------------
>
> Key: TEIID-1991
> URL: https://issues.jboss.org/browse/TEIID-1991
> Project: Teiid
> Issue Type: Bug
> Components: Query Engine
> Affects Versions: 7.7
> Reporter: Mark Addleman
> Assignee: Steven Hawkins
> Attachments: efficient_rewrite.txt, plan.txt, plan.txt, simplified_plan.txt
>
>
> If have a query of the form
> SELECT a FROM (
> SELECT a FROM (
> SELECT a FROM ds.t1
> ) u
> ) t GROUP BY a
> Teiid correctly optimizes the inner SELECT to SELECT 1 FROM ds.t1. However, if the inner subselect is a union:
> SELECT a FROM (
> SELECT a FROM (
> SELECT a FROM ds.t1 UNION
> SELECT a FROM ds.t2
> ) u
> ) t GROUP BY a
>
> Teiid does not optimize to
> SELECT 1 FROM ds.t1 UNION
> SELECT 1 FROM ds.t2
> as I would expect.
> See attached plan
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the teiid-issues
mailing list