org.teiid.query.rewriter
Class QueryRewriter

java.lang.Object
  extended by org.teiid.query.rewriter.QueryRewriter

public class QueryRewriter
extends java.lang.Object

Rewrites commands and command fragments to a form that is better for planning and execution. There is a current limitation that command objects themselves cannot change type, since the same object is always used.


Field Summary
static CompareCriteria FALSE_CRITERIA
           
static CompareCriteria TRUE_CRITERIA
           
static CompareCriteria UNKNOWN_CRITERIA
           
 
Method Summary
static Query createInlineViewQuery(GroupSymbol group, Command nested, QueryMetadataInterface metadata, java.util.List<SingleElementSymbol> actualSymbols)
           
static Command evaluateAndRewrite(Command command, Evaluator eval, CommandContext context, QueryMetadataInterface metadata)
           
static boolean isDistinctWithGroupBy(Query query)
           
static boolean isNull(Expression expr)
           
static void makeSelectUnique(Select select, boolean expressionSymbolsOnly)
           
static Criteria optimizeCriteria(CompoundCriteria criteria, QueryMetadataInterface metadata)
          Performs simple expression flattening
static Command rewrite(Command command, CreateUpdateProcedureCommand procCommand, QueryMetadataInterface metadata, CommandContext context, java.util.Map variableValues, int commandType)
           
static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context)
           
static Criteria rewriteCriteria(Criteria criteria, CreateUpdateProcedureCommand procCommand, CommandContext context, QueryMetadataInterface metadata)
          Rewrite the criteria by evaluating some trivial cases.
static Expression rewriteExpression(Expression expression, CreateUpdateProcedureCommand procCommand, CommandContext context, QueryMetadataInterface metadata)
           
 QueryCommand rewriteOrderBy(QueryCommand queryCommand)
          Rewrite the order by clause.
static boolean rewriteOrderBy(QueryCommand queryCommand, OrderBy orderBy, java.util.List projectedSymbols, java.util.LinkedList<OrderByItem> unrelatedItems)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUE_CRITERIA

public static final CompareCriteria TRUE_CRITERIA

FALSE_CRITERIA

public static final CompareCriteria FALSE_CRITERIA

UNKNOWN_CRITERIA

public static final CompareCriteria UNKNOWN_CRITERIA
Method Detail

evaluateAndRewrite

public static Command evaluateAndRewrite(Command command,
                                         Evaluator eval,
                                         CommandContext context,
                                         QueryMetadataInterface metadata)
                                  throws TeiidProcessingException,
                                         TeiidComponentException
Throws:
TeiidProcessingException
TeiidComponentException

rewrite

public static Command rewrite(Command command,
                              CreateUpdateProcedureCommand procCommand,
                              QueryMetadataInterface metadata,
                              CommandContext context,
                              java.util.Map variableValues,
                              int commandType)
                       throws TeiidComponentException,
                              TeiidProcessingException
Throws:
TeiidComponentException
TeiidProcessingException

rewrite

public static Command rewrite(Command command,
                              QueryMetadataInterface metadata,
                              CommandContext context)
                       throws TeiidComponentException,
                              TeiidProcessingException
Throws:
TeiidComponentException
TeiidProcessingException

isDistinctWithGroupBy

public static boolean isDistinctWithGroupBy(Query query)

rewriteOrderBy

public QueryCommand rewriteOrderBy(QueryCommand queryCommand)
                            throws TeiidComponentException
Rewrite the order by clause. Unrelated order by expressions will cause the creation of nested inline views.

Parameters:
query -
Throws:
TeiidComponentException, - MetaMatrixProcessingException
TeiidComponentException

rewriteOrderBy

public static boolean rewriteOrderBy(QueryCommand queryCommand,
                                     OrderBy orderBy,
                                     java.util.List projectedSymbols,
                                     java.util.LinkedList<OrderByItem> unrelatedItems)

rewriteCriteria

public static Criteria rewriteCriteria(Criteria criteria,
                                       CreateUpdateProcedureCommand procCommand,
                                       CommandContext context,
                                       QueryMetadataInterface metadata)
                                throws TeiidComponentException,
                                       TeiidProcessingException
Rewrite the criteria by evaluating some trivial cases.

Parameters:
criteria - The criteria to rewrite
metadata -
userCriteria - The criteria on user's command, used in rewriting HasCriteria in the procedural language.
Returns:
The re-written criteria
Throws:
TeiidComponentException
TeiidProcessingException

optimizeCriteria

public static Criteria optimizeCriteria(CompoundCriteria criteria,
                                        QueryMetadataInterface metadata)
Performs simple expression flattening

Parameters:
criteria -
Returns:

isNull

public static boolean isNull(Expression expr)

rewriteExpression

public static Expression rewriteExpression(Expression expression,
                                           CreateUpdateProcedureCommand procCommand,
                                           CommandContext context,
                                           QueryMetadataInterface metadata)
                                    throws TeiidComponentException,
                                           TeiidProcessingException
Throws:
TeiidComponentException
TeiidProcessingException

createInlineViewQuery

public static Query createInlineViewQuery(GroupSymbol group,
                                          Command nested,
                                          QueryMetadataInterface metadata,
                                          java.util.List<SingleElementSymbol> actualSymbols)
                                   throws QueryMetadataException,
                                          QueryResolverException,
                                          TeiidComponentException
Throws:
QueryMetadataException
QueryResolverException
TeiidComponentException

makeSelectUnique

public static void makeSelectUnique(Select select,
                                    boolean expressionSymbolsOnly)


Copyright © 2010. All Rights Reserved.