org.apache.hadoop.hive.ql.optimizer.index
Class RewriteGBUsingIndex
java.lang.Object
org.apache.hadoop.hive.ql.optimizer.index.RewriteGBUsingIndex
- All Implemented Interfaces:
- Transform
public class RewriteGBUsingIndex
- extends Object
- implements Transform
RewriteGBUsingIndex is implemented as one of the Rule-based Optimizations.
Implements optimizations for GroupBy clause rewrite using aggregate index.
This optimization rewrites GroupBy query over base table to the query over simple table-scan
over index table, if there is index on the group by key(s) or the distinct column(s).
E.g.
select count(key)
from table
group by key;
to
select sum(_count_of_key)
from idx_table
group by key;
The rewrite supports following queries:
- Queries having only those col refs that are in the index key.
- Queries that have index key col refs
- in SELECT
- in WHERE
- in GROUP BY
- Queries with agg func COUNT(index key col ref) in SELECT
- Queries with SELECT DISTINCT index_key_col_refs
- Queries having a subquery satisfying above condition (only the subquery is rewritten)
- See Also:
AggregateIndexHandler
,
IndexUtils
,
RewriteCanApplyCtx
,
RewriteCanApplyProcFactory
,
RewriteParseContextGenerator
,
RewriteQueryUsingAggregateIndexCtx
,
For test cases, @see ql_rewrite_gbtoidx.q
RewriteGBUsingIndex
public RewriteGBUsingIndex()
transform
public ParseContext transform(ParseContext pctx)
throws SemanticException
- Description copied from interface:
Transform
- All transformation steps implement this interface.
- Specified by:
transform
in interface Transform
- Parameters:
pctx
- input parse context
- Returns:
- ParseContext
- Throws:
SemanticException
Copyright © 2014 The Apache Software Foundation. All rights reserved.