@Override public PlanNode getDescriptionProperties() { PlanNode props = super.getDescriptionProperties(); props.addProperty(PROP_SQL, this.command.toString()); return props; }
/** * Deep clone statement to produce a new identical statement. * @return Deep clone */ public Object clone() { CommandStatement cs = new CommandStatement((Command)this.command.clone()); cs.returnable = this.returnable; return cs; }
protected void validateHasProjectedSymbols(Command obj) { if(obj.getProjectedSymbols().size() == 0) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0025"), obj); //$NON-NLS-1$ } }
/** * @return null if unknown, empty if results are not returned, or the resultset columns */ public List<? extends Expression> getResultSetColumns() { if (returnsResultSet()) { return getProjectedSymbols(); } return Collections.emptyList(); }
public static void setChildMetadata(Command subCommand, Command parent) { TempMetadataStore childMetadata = parent.getTemporaryMetadata(); GroupContext parentContext = parent.getExternalGroupContexts(); setChildMetadata(subCommand, childMetadata, parentContext); }
/** * Helper method to print command tree at given tab level * @param str String buffer to add command sub tree to * @param tabLevel Number of tabs to print this command at */ protected void printCommandTree(StringBuffer str, int tabLevel) { // Add tabs for(int i=0; i<tabLevel; i++) { str.append("\t"); //$NON-NLS-1$ } // Add this command str.append(toString()); str.append("\n"); //$NON-NLS-1$ // Add children recursively tabLevel++; for (Command subCommand : CommandCollectorVisitor.getCommands(this)) { subCommand.printCommandTree(str, tabLevel); } }
@Test public void testClone() throws Exception { String sql = "select * from objecttable(language 'x' 'teiid_context' COLUMNS y string 'teiid_row.userName') as X"; //$NON-NLS-1$ Command c = QueryParser.getQueryParser().parseCommand(sql); assertEquals("SELECT * FROM OBJECTTABLE(LANGUAGE 'x' 'teiid_context' COLUMNS y string 'teiid_row.userName') AS X", c.toString()); assertEquals("SELECT * FROM OBJECTTABLE(LANGUAGE 'x' 'teiid_context' COLUMNS y string 'teiid_row.userName') AS X", c.clone().toString()); }
QueryPlannerException { try { command = (Command)command.clone(); boolean aliasGroups = modelID != null && (CapabilitiesUtil.supportsGroupAliases(modelID, metadata, capFinder) || CapabilitiesUtil.supports(Capability.QUERY_FROM_INLINE_VIEWS, modelID, metadata, capFinder)); || CapabilitiesUtil.supports(Capability.QUERY_FROM_INLINE_VIEWS, modelID, metadata, capFinder)); AliasGenerator visitor = new AliasGenerator(aliasGroups, !aliasColumns); SourceHint sh = command.getSourceHint(); if (sh != null && aliasGroups) { VDBMetaData vdb = context.getDQPWorkContext().getVDB(); command.acceptVisitor(visitor); } catch (QueryMetadataException err) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30249, err);
if (command.getResultSetColumns() == null && cmdStmt.isReturnable() && subCommand.returnsResultSet() && subCommand.getResultSetColumns() != null && !subCommand.getResultSetColumns().isEmpty()) { command.setResultSetColumns(subCommand.getResultSetColumns()); if (command.getProjectedSymbols().isEmpty()) { command.setProjectedSymbols(subCommand.getResultSetColumns()); Command cmd = loopStmt.getCommand(); resolveEmbeddedCommand(metadata, externalGroups, cmd); List<Expression> symbols = cmd.getProjectedSymbols();
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; }
@Test public void testTextTableAliasWithPeriod() throws Exception { Command command = helpResolve("select \"x.y.z\".*, \"x.y.z\".x from pm1.g1, texttable(e1 COLUMNS x string) \"x.y.z\""); //$NON-NLS-1$ assertEquals(2, command.getProjectedSymbols().size()); assertEquals("SELECT \"x.y.z\".*, \"x.y.z\".x FROM pm1.g1, TEXTTABLE(e1 COLUMNS x string) AS \"x.y.z\"", command.toString()); assertEquals("SELECT \"x.y.z\".*, \"x.y.z\".x FROM pm1.g1, TEXTTABLE(e1 COLUMNS x string) AS \"x.y.z\"", command.clone().toString()); }
public static void setChildMetadata(Command subCommand, TempMetadataStore parentTempMetadata, GroupContext parentContext) { TempMetadataStore tempMetadata = subCommand.getTemporaryMetadata(); if(tempMetadata == null) { subCommand.setTemporaryMetadata(parentTempMetadata.clone()); } else { tempMetadata.getData().putAll(parentTempMetadata.getData()); } subCommand.setExternalGroupContexts(parentContext); }
private void discoverWith( LinkedHashMap<String, WithQueryCommand> pushdownWith, Command command, List<WithQueryCommand> with, Collection<GroupSymbol> groups) throws QueryMetadataException, TeiidComponentException { for (GroupSymbol groupSymbol : groups) { if (!groupSymbol.isPushedCommonTable()) { continue; } WithQueryCommand clause = pushdownWith.get(groupSymbol.getNonCorrelationName()); if (clause == null) { continue; } TreeSet<GroupSymbol> temp = new TreeSet<GroupSymbol>(nonCorrelatedComparator); GroupCollectorVisitor.getGroupsIgnoreInlineViewsAndEvaluatableSubqueries(clause.getCommand(), temp); temp.removeAll(this.withGroups); discoverWith(pushdownWith, command, with, temp); with.add(clause.clone()); this.withGroups.add(clause.getGroupSymbol()); command.setSourceHint(SourceHint.combine(command.getSourceHint(), clause.getCommand().getSourceHint())); } }
Integer.toString(requestID.getExecutionId()), this); SourceHint hint = message.getCommand().getSourceHint(); if (hint != null) { this.securityContext.setGeneralHints(hint.getGeneralHints()); List<Expression> symbols = this.requestMsg.getCommand().getProjectedSymbols(); this.schema = new Class[symbols.size()]; this.convertToDesiredRuntimeType = new boolean[symbols.size()];
/** * Get the ordered list of all elements returned by this query. These elements * may be ElementSymbols or ExpressionSymbols but in all cases each represents a * single column. * @return Ordered list of SingleElementSymbol */ public List<Expression> getProjectedSymbols(){ return Command.getUpdateCommandSymbol(); }
public static Boolean requiresTransaction(boolean transactionalReads, List<SubqueryContainer<?>> valueIteratorProviders) { for (SubqueryContainer<?> subquery : valueIteratorProviders) { ProcessorPlan plan = subquery.getCommand().getProcessorPlan(); if (plan != null) { Boolean txn = plan.requiresTransaction(transactionalReads); if (txn == null || txn) { return true; //we can't ensure that this is read only } } } return false; }
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(); }
this.sourceHint = SourceHint.combine(previous, command.getSourceHint()); Command original = (Command) command.clone(); List<Expression> topCols = Util.deepClone(command.getProjectedSymbols(), Expression.class);
@Override public void visit(CommandStatement obj) { if (this.createProc == null || this.createProc.getResultSetColumns().isEmpty() || !obj.isReturnable() || !obj.getCommand().returnsResultSet()) { return; } List<? extends Expression> symbols = obj.getCommand().getResultSetColumns(); if (symbols == null && obj.getCommand() instanceof DynamicCommand) { DynamicCommand cmd = (DynamicCommand)obj.getCommand(); cmd.setAsColumns(this.createProc.getResultSetColumns()); return; } try { QueryResolver.validateProjectedSymbols(createProc.getVirtualGroup(), createProc.getResultSetColumns(), symbols); } catch (QueryValidatorException e) { handleValidationError(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31121, createProc.getVirtualGroup(), obj, e.getMessage()), obj); } }
@Override public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException { if (hints[i*2] == null && hints[i*2+1] == null) { assertNull(command.getSourceHint()); } else { assertEquals(hints[i*2], command.getSourceHint().getGeneralHint()); //$NON-NLS-1$ assertEquals(hints[i*2+1], command.getSourceHint().getSourceHint("bar")); //$NON-NLS-1$ } i = ++i%(hints.length/2); if (getData(command.toString()) != null) { return super.registerRequest(context, command, modelName, parameterObject); } return CollectionTupleSource.createNullTupleSource(); } };