Package org.teiid.query.rewriter
Class QueryRewriter
- java.lang.Object
-
- org.teiid.query.rewriter.QueryRewriter
-
public class QueryRewriter extends 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
Fields Modifier and Type Field Description static CompareCriteria
FALSE_CRITERIA
static CompareCriteria
TRUE_CRITERIA
static CompareCriteria
UNKNOWN_CRITERIA
-
Method Summary
-
-
-
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
-
evaluateAndRewrite
public static Criteria evaluateAndRewrite(Criteria criteria, Evaluator eval, CommandContext context, QueryMetadataInterface metadata) throws TeiidProcessingException, TeiidComponentException
-
rewrite
public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context, Map<ElementSymbol,Expression> variableValues) throws TeiidComponentException, TeiidProcessingException
-
rewrite
public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context) throws TeiidComponentException, TeiidProcessingException
-
isDistinctWithGroupBy
public static boolean isDistinctWithGroupBy(Query query)
-
rewriteOrderBy
public QueryCommand rewriteOrderBy(QueryCommand queryCommand) throws TeiidComponentException, TeiidProcessingException
Rewrite the order by clause. Unrelated order by expressions will cause the creation of nested inline views.- Parameters:
queryCommand
-- Throws:
TeiidComponentException
TeiidProcessingException
-
rewriteOrderBy
public static void rewriteOrderBy(QueryCommand queryCommand, OrderBy orderBy, List projectedSymbols, CommandContext context, QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException
-
rewriteCriteria
public static Criteria rewriteCriteria(Criteria criteria, CommandContext context, QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException
Rewrite the criteria by evaluating some trivial cases.- Parameters:
criteria
- The criteria to rewritemetadata
-- 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, CommandContext context, QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException
-
rewriteExpression
public static Expression rewriteExpression(Expression expression, CommandContext context, QueryMetadataInterface metadata, boolean rewriteSubcommands) throws TeiidComponentException, TeiidProcessingException
-
rewriteAsUpsertProcedure
public static Command rewriteAsUpsertProcedure(Insert insert, QueryMetadataInterface metadata, CommandContext context) throws TeiidComponentException, QueryMetadataException, QueryValidatorException, QueryResolverException, TeiidProcessingException
-
createInlineViewQuery
public static Query createInlineViewQuery(GroupSymbol inlineGroup, Command nested, QueryMetadataInterface metadata, List<? extends Expression> actualSymbols) throws QueryMetadataException, QueryResolverException, TeiidComponentException
-
makeSelectUnique
public static void makeSelectUnique(Select select, boolean expressionSymbolsOnly)
-
createDeleteProcedure
public static Command createDeleteProcedure(Delete delete, QueryMetadataInterface metadata, CommandContext context) throws QueryResolverException, QueryMetadataException, TeiidComponentException, TeiidProcessingException
-
createUpdateProcedure
public static Command createUpdateProcedure(Update update, QueryMetadataInterface metadata, CommandContext context) throws QueryResolverException, QueryMetadataException, TeiidComponentException, TeiidProcessingException
-
-