@Test public void testStoredProcedure_9822() throws Exception { QueryParser parser = new QueryParser(); Command command = parser.parseCommand("exec pm1.sp4(5)"); QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); QueryResolver.resolveCommand(command, metadata); Command rewriteCommand = QueryRewriter.rewrite(command, metadata, null); Collection<SPParameter> parameters = ((StoredProcedure)rewriteCommand).getParameters(); for (SPParameter param : parameters) { if(param.getParameterType() == ParameterInfo.IN || param.getParameterType() == ParameterInfo.INOUT){ assertTrue(param.getExpression() instanceof Constant); } } }
public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context, Map<ElementSymbol, Expression> variableValues) throws TeiidComponentException, TeiidProcessingException{ QueryRewriter rewriter = new QueryRewriter(metadata, context); rewriter.rewriteSubcommands = true; rewriter.variables = variableValues; return rewriter.rewriteCommand(command, false); }
QueryRewriter { public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context, Map<ElementSymbol, Expression> variableValues) throws TeiidComponentException, TeiidProcessingException{ QueryRewriter rewriter = new QueryRewriter(metadata, context); rewriter.rewriteSubcommands = true; rewriter.variables = variableValues; return rewriter.rewriteCommand(command, false); } }
QueryRewriter { public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context, Map<ElementSymbol, Expression> variableValues) throws TeiidComponentException, TeiidProcessingException{ QueryRewriter rewriter = new QueryRewriter(metadata, context); rewriter.rewriteSubcommands = true; rewriter.variables = variableValues; return rewriter.rewriteCommand(command, false); } private  QueryRewriter(QueryMetadataInterface metadata,
            CommandContext context); }
QueryRewriter { public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context, Map<ElementSymbol, Expression> variableValues) throws TeiidComponentException, TeiidProcessingException{ QueryRewriter rewriter = new QueryRewriter(metadata, context); rewriter.rewriteSubcommands = true; rewriter.variables = variableValues; return rewriter.rewriteCommand(command, false); } private  QueryRewriter(QueryMetadataInterface metadata,
            CommandContext context); static Command evaluateAndRewrite(Command command, Evaluator eval, CommandContext context, QueryMetadataInterface metadata); static Criteria evaluateAndRewrite(Criteria criteria, Evaluator eval, CommandContext context, QueryMetadataInterface metadata); static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context, Map<ElementSymbol, Expression> variableValues); static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context); static boolean isDistinctWithGroupBy(Query query); QueryCommand rewriteOrderBy(QueryCommand queryCommand); static void rewriteOrderBy(QueryCommand queryCommand,
            final OrderBy orderBy, final List projectedSymbols, CommandContext context, QueryMetadataInterface metadata); static Criteria rewriteCriteria(Criteria criteria, CommandContext context, QueryMetadataInterface metadata); static Criteria optimizeCriteria(CompoundCriteria criteria, QueryMetadataInterface metadata); static boolean isNull(Expression expr); static Expression rewriteExpression(Expression expression, CommandContext context, QueryMetadataInterface metadata); static Expression rewriteExpression(Expression expression, CommandContext context, QueryMetadataInterface metadata, boolean rewriteSubcommands); static Command rewriteAsUpsertProcedure(Insert insert, QueryMetadataInterface metadata, CommandContext context); static Query createInlineViewQuery(GroupSymbol inlineGroup,
                                               Command nested,
                                               QueryMetadataInterface metadata,
                                               List<? extends Expression> actualSymbols); static void makeSelectUnique(Select select, boolean expressionSymbolsOnly); static Command createDeleteProcedure(Delete delete, QueryMetadataInterface metadata, CommandContext context); static Command createUpdateProcedure(Update update, QueryMetadataInterface metadata, CommandContext context); }
QueryRewriter { public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context, Map<ElementSymbol, Expression> variableValues) throws TeiidComponentException, TeiidProcessingException{ QueryRewriter rewriter = new QueryRewriter(metadata, context); rewriter.rewriteSubcommands = true; rewriter.variables = variableValues; return rewriter.rewriteCommand(command, false); } private  QueryRewriter(QueryMetadataInterface metadata,
            CommandContext context); static Command evaluateAndRewrite(Command command, Evaluator eval, CommandContext context, QueryMetadataInterface metadata); static Criteria evaluateAndRewrite(Criteria criteria, Evaluator eval, CommandContext context, QueryMetadataInterface metadata); static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context, Map<ElementSymbol, Expression> variableValues); static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context); static boolean isDistinctWithGroupBy(Query query); QueryCommand rewriteOrderBy(QueryCommand queryCommand); static void rewriteOrderBy(QueryCommand queryCommand,
            final OrderBy orderBy, final List projectedSymbols, CommandContext context, QueryMetadataInterface metadata); static Criteria rewriteCriteria(Criteria criteria, CommandContext context, QueryMetadataInterface metadata); static Criteria optimizeCriteria(CompoundCriteria criteria, QueryMetadataInterface metadata); static boolean isNull(Expression expr); static Expression rewriteExpression(Expression expression, CommandContext context, QueryMetadataInterface metadata); static Expression rewriteExpression(Expression expression, CommandContext context, QueryMetadataInterface metadata, boolean rewriteSubcommands); static Command rewriteAsUpsertProcedure(Insert insert, QueryMetadataInterface metadata, CommandContext context); static Query createInlineViewQuery(GroupSymbol inlineGroup,
                                               Command nested,
                                               QueryMetadataInterface metadata,
                                               List<? extends Expression> actualSymbols); static void makeSelectUnique(Select select, boolean expressionSymbolsOnly); static Command createDeleteProcedure(Delete delete, QueryMetadataInterface metadata, CommandContext context); static Command createUpdateProcedure(Update update, QueryMetadataInterface metadata, CommandContext context); static final CompareCriteria TRUE_CRITERIA; static final CompareCriteria FALSE_CRITERIA; static final CompareCriteria UNKNOWN_CRITERIA; }