Hi Mihir, I am almost certain that both the queries will compile to the same MR plan in hive (I haven't checked though).
In fact, having clause is a syntactic sugar to achieve whats done in the nested query. Take a look at: https://issues.apache.org/jira/browse/HIVE-1790 Thanks, Aniket On Wed, Jun 26, 2013 at 10:46 PM, Mihir Kulkarni <mihirk...@gmail.com>wrote: > Hello, > > Does hive support Query Flattening? For example a query like this: > > *SELECT alias.a0, alias.a1* > *FROM* > * (SELECT COUNT(b) AS a0, c AS a1* > * FROM test* > * GROUP BY c) alias* > *WHERE alias.a0 > 2;* > * > * > would be flattened into: > > *SELECT COUNT(b), c* > *FROM test* > *GROUP BY c* > *HAVING COUNT(b) > 2;* > > Does Hive (0.11) have such kind of optimizations or are they even useful > considering all queries are ultimately converted into MapReduce jobs? At > Informatica Corp we rely on Hive a lot and hence are interested to support > such optimizations. > > Thanks in anticipation. > > Regards, > *---* > *Mihir Kulkarni > **Software Engineer | Data Engine > Informatica Corporation* > -- "...:::Aniket:::... Quetzalco@tl"