db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manish Khettry (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-681) Eliminate the parser's rewriting of the abstract syntax tree for queries with GROUP BY and/or HAVING clauses
Date Wed, 14 Feb 2007 21:57:06 GMT

    [ https://issues.apache.org/jira/browse/DERBY-681?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12473218

Manish Khettry commented on DERBY-681:

Just a quick note to address two issues raised by Army.

DERBY-1624: It won't fix all the queries attached by Andrew for this bug because we don't
resolve aliases in the group by/having/orderby clauses; the following query will fail. This
bug does not address aliases-- only the original query with this bug.

select x as alias, sum(y)
from t 
group by alias;

The size vs visible size is more problematic-- I really think the language layer should not
be using RCL directly as much as it currently does. If it wants to check the number of columns
returned by a ResultSetNode, it should call a method in the RSN called either visibleSize
or runtimeSize  or some such (i.e. the # of columns actually returned by the result set node).
The only way to find all of these would be to grind through all the occurences of RCL.size!
This in itself should suggest that the use of these classes/methods in this little area itself
(i.e. # of columns in a result set node) could deal with a good dose of refactoring. 

Thanks for looking at the patch, running tests and asking the right questions. I appreciate
the time you've taken for this patch. I am a little busy at work but will get back to this
bug when things let up (hopefully next week). 

> Eliminate the parser's rewriting of the abstract syntax tree for queries with GROUP BY
and/or HAVING clauses
> ------------------------------------------------------------------------------------------------------------
>                 Key: DERBY-681
>                 URL: https://issues.apache.org/jira/browse/DERBY-681
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>            Reporter: Rick Hillegas
>         Assigned To: Manish Khettry
>         Attachments: 681.patch.txt, notes.txt
> If a query contains a GROUP BY or HAVING clause, the parser rewrites the abstract syntax
tree, putting aggregates into a subselect and treating the HAVING clause as the WHERE clause
of a fabricated outer select from the subquery. This allows the compiler to re-use some machinery
since the HAVING clause operates on the grouped result the way that the WHERE clause operates
on the from list. Unfortunately, this rewriting creates an explosion of special cases in the
compiler after parsing is done. The rewriting is not systematically handled later on in the
compiler. This gives rise to defects like bug 280. We need to eliminate this special rewriting
and handle the HAVING clause in a straightforward way. This is not a small bugfix but is a
medium sized project.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message