public static final List<Command> getCommands(Command command, boolean includeExpanded) { CommandCollectorVisitor visitor = new CommandCollectorVisitor(); visitor.collectExpanded = includeExpanded; final boolean visitCommands = command instanceof SetQuery; PreOrderNavigator navigator = new PreOrderNavigator(visitor) { @Override protected void visitNode(LanguageObject obj) { if (!visitCommands && obj instanceof Command) { return; } super.visitNode(obj); } }; command.acceptVisitor(navigator); return visitor.getCommands(); }
public static final List<Command> getCommands(Command command, boolean includeExpanded) { CommandCollectorVisitor visitor = new CommandCollectorVisitor(); visitor.collectExpanded = includeExpanded; final boolean visitCommands = command instanceof SetQuery; PreOrderNavigator navigator = new PreOrderNavigator(visitor) { @Override protected void visitNode(LanguageObject obj) { if (!visitCommands && obj instanceof Command) { return; } super.visitNode(obj); } }; command.acceptVisitor(navigator); return visitor.getCommands(); }
public static final List<Command> getCommands(Command command, boolean includeExpanded) { CommandCollectorVisitor visitor = new CommandCollectorVisitor(); visitor.collectExpanded = includeExpanded; final boolean visitCommands = command instanceof SetQuery; PreOrderNavigator navigator = new PreOrderNavigator(visitor) { @Override protected void visitNode(LanguageObject obj) { if (!visitCommands && obj instanceof Command) { return; } super.visitNode(obj); } }; command.acceptVisitor(navigator); return visitor.getCommands(); }
public static void visit(String bindingName, QueryMetadataInterface metadata, Command processingCommand) { MultiSourceElementReplacementVisitor visitor = new MultiSourceElementReplacementVisitor(bindingName, metadata); PreOrPostOrderNavigator nav = new PreOrPostOrderNavigator(visitor, PreOrPostOrderNavigator.PRE_ORDER, true); nav.setSkipEvaluatable(true); processingCommand.acceptVisitor(nav); }
@Override public void open() throws TeiidComponentException, TeiidProcessingException { AlterProcessor ap = new AlterProcessor(); try { command.acceptVisitor(ap); } catch (TeiidRuntimeException e) { if (e.getCause() instanceof TeiidProcessingException) { throw (TeiidProcessingException)e.getCause(); } throw e; } }
@Override public void open() throws TeiidComponentException, TeiidProcessingException { AlterProcessor ap = new AlterProcessor(); try { command.acceptVisitor(ap); } catch (TeiidRuntimeException e) { if (e.getCause() instanceof TeiidProcessingException) { throw (TeiidProcessingException)e.getCause(); } throw e; } }
@Override public void open() throws TeiidComponentException, TeiidProcessingException { AlterProcessor ap = new AlterProcessor(); try { command.acceptVisitor(ap); } catch (TeiidRuntimeException e) { if (e.getCause() instanceof TeiidProcessingException) { throw (TeiidProcessingException)e.getCause(); } throw e; } }
public static void visit(String bindingName, QueryMetadataInterface metadata, Command processingCommand) { MultiSourceElementReplacementVisitor visitor = new MultiSourceElementReplacementVisitor(bindingName, metadata); PreOrPostOrderNavigator nav = new PreOrPostOrderNavigator(visitor, PreOrPostOrderNavigator.PRE_ORDER, true); nav.setSkipEvaluatable(true); processingCommand.acceptVisitor(nav); }
public static void visit(String bindingName, QueryMetadataInterface metadata, Command processingCommand) { MultiSourceElementReplacementVisitor visitor = new MultiSourceElementReplacementVisitor(bindingName, metadata); PreOrPostOrderNavigator nav = new PreOrPostOrderNavigator(visitor, PreOrPostOrderNavigator.PRE_ORDER, true); nav.setSkipEvaluatable(true); processingCommand.acceptVisitor(nav); }
public void visit(SubqueryFromClause obj) { visitor.createChildNamingContext(true); //first determine the original names List<Expression> exprs = obj.getCommand().getProjectedSymbols(); List<String> names = new ArrayList<String>(exprs.size()); for (int i = 0; i < exprs.size(); i++) { names.add(Symbol.getShortName(exprs.get(i))); } obj.getCommand().acceptVisitor(this); Map<String, String> viewGroup = new HashMap<String, String>(); int i = 0; //now map to the new names for (Entry<Expression, String> entry : visitor.namingContext.currentSymbols.entrySet()) { viewGroup.put(names.get(i++), entry.getValue()); } visitor.namingContext.parent.elementMap.put(obj.getName(), viewGroup); visitor.removeChildNamingContext(); obj.getGroupSymbol().setName(recontextGroup(obj.getGroupSymbol(), true)); }
public void visit(SubqueryFromClause obj) { visitor.createChildNamingContext(true); //first determine the original names List<Expression> exprs = obj.getCommand().getProjectedSymbols(); List<String> names = new ArrayList<String>(exprs.size()); for (int i = 0; i < exprs.size(); i++) { names.add(Symbol.getShortName(exprs.get(i))); } obj.getCommand().acceptVisitor(this); Map<String, String> viewGroup = new HashMap<String, String>(); int i = 0; //now map to the new names for (Entry<Expression, String> entry : visitor.namingContext.currentSymbols.entrySet()) { viewGroup.put(names.get(i++), entry.getValue()); } visitor.namingContext.parent.elementMap.put(obj.getName(), viewGroup); visitor.removeChildNamingContext(); obj.getGroupSymbol().setName(recontextGroup(obj.getGroupSymbol(), true)); }
public void visit(SubqueryFromClause obj) { visitor.createChildNamingContext(true); //first determine the original names List<Expression> exprs = obj.getCommand().getProjectedSymbols(); List<String> names = new ArrayList<String>(exprs.size()); for (int i = 0; i < exprs.size(); i++) { names.add(Symbol.getShortName(exprs.get(i))); } obj.getCommand().acceptVisitor(this); Map<String, String> viewGroup = new HashMap<String, String>(); int i = 0; //now map to the new names for (Entry<Expression, String> entry : visitor.namingContext.currentSymbols.entrySet()) { viewGroup.put(names.get(i++), entry.getValue()); } visitor.namingContext.parent.elementMap.put(obj.getName(), viewGroup); visitor.removeChildNamingContext(); obj.getGroupSymbol().setName(recontextGroup(obj.getGroupSymbol(), true)); }
/** * Add to the navigation the visitation of expanded commands * which are inlined with clauses */ @Override public void visit(UnaryFromClause obj) { super.visit(obj); if (obj.getExpandedCommand() != null && !obj.getGroup().isProcedure()) { obj.getExpandedCommand().acceptVisitor(this); } } };
/** * Add to the navigation the visitation of expanded commands * which are inlined with clauses */ @Override public void visit(UnaryFromClause obj) { super.visit(obj); if (obj.getExpandedCommand() != null && !obj.getGroup().isProcedure()) { obj.getExpandedCommand().acceptVisitor(this); } } };
/** * Add to the navigation the visitation of expanded commands * which are inlined with clauses */ @Override public void visit(UnaryFromClause obj) { super.visit(obj); if (obj.getExpandedCommand() != null && !obj.getGroup().isProcedure()) { obj.getExpandedCommand().acceptVisitor(this); } } };
private Command helpTest(String sql, String expected, QueryMetadataInterface metadata, AliasGenerator visitor) throws TeiidComponentException, TeiidProcessingException { Command command = TestResolver.helpResolve(sql, metadata); command = QueryRewriter.rewrite(command, metadata, null); command = (Command) command.clone(); command.acceptVisitor(visitor); assertEquals(expected, command.toString()); return command; }
public static void checkAtomicQueries(String[] expectedAtomic, ProcessorPlan plan, QueryMetadataInterface md, CapabilitiesFinder capFinder) { Set<String> actualQueries = getAtomicQueries(plan); HashSet<String> expectedQueries = new HashSet<String>(); // Compare atomic queries for (int i = 0; i < expectedAtomic.length; i++) { final String sql = expectedAtomic[i]; Command command; try { command = helpGetCommand(sql, md); Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(command, false); final GroupSymbol symbol = groups.iterator().next(); Object modelId = md.getModelID(symbol.getMetadataID()); boolean supportsGroupAliases = CapabilitiesUtil.supportsGroupAliases(modelId, md, capFinder); boolean supportsProjection = CapabilitiesUtil.supports(Capability.QUERY_SELECT_EXPRESSION, modelId, md, capFinder); command.acceptVisitor(new AliasGenerator(supportsGroupAliases, !supportsProjection)); expectedQueries.add(command.toString()); } catch (Exception err) { throw new RuntimeException(err); } } assertEquals("Did not get expected atomic queries: ", expectedQueries, actualQueries); //$NON-NLS-1$ }
command.acceptVisitor(visitor); } catch (QueryMetadataException err) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30249, err);
command.acceptVisitor(visitor); } catch (QueryMetadataException err) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30249, err);
if (generateAliases) { command = (Command)command.clone(); command.acceptVisitor(new AliasGenerator(supportsGroupAlias));