TempTable getOrCreateTempTable( String tempTableID, Command command, BufferManager buffer, boolean delegate, boolean forUpdate, CommandContext context) throws TeiidProcessingException, BlockedException, TeiidComponentException { TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate, forUpdate, context); if (tempTable != null) { if (processors != null) { TableProcessor withProcessor = processors.get(tempTableID); if (withProcessor != null) { buildWithTable(tempTableID, withProcessor, tempTable); } } return tempTable; } // allow implicit temp group definition List<ElementSymbol> columns = null; if (command instanceof Insert) { Insert insert = (Insert) command; GroupSymbol group = insert.getGroup(); if (group.isImplicitTempGroupSymbol()) { columns = insert.getVariables(); } } if (columns == null) { if (processors != null) { TableProcessor withProcessor = processors.get(tempTableID); if (withProcessor != null) { LogManager.logDetail( LogConstants.CTX_DQP, "Creating temporary table for with clause", tempTableID); //$NON-NLS-1$ Create create = new Create(); create.setTable(new GroupSymbol(tempTableID)); create.setElementSymbolsAsColumns(withProcessor.columns); tempTable = addTempTable(tempTableID, create, buffer, true, context); buildWithTable(tempTableID, withProcessor, tempTable); return tempTable; } } throw new QueryProcessingException( QueryPlugin.Event.TEIID30226, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30226, tempTableID)); } LogManager.logDetail( LogConstants.CTX_DQP, "Creating temporary table", tempTableID); // $NON-NLS-1$ Create create = new Create(); create.setTable(new GroupSymbol(tempTableID)); create.setElementSymbolsAsColumns(columns); return addTempTable(tempTableID, create, buffer, true, context); }
@Override public void visit(Insert obj) { preVisitVisitor(obj); visitNode(obj.getGroup()); visitNodes(obj.getVariables()); visitNodes(obj.getValues()); if (deep && obj.getQueryExpression() != null) { visitNode(obj.getQueryExpression()); } visitNode(obj.getOption()); postVisitVisitor(obj); }
/** * Compare two Insert commands for equality. Will only evaluate to equal if they are IDENTICAL: * group is equal, value is equal and variables are equal. * * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { // Quick same object test if (this == obj) { return true; } // Quick fail tests if (!(obj instanceof Insert)) { return false; } Insert other = (Insert) obj; return EquivalenceUtil.areEqual(getGroup(), other.getGroup()) && EquivalenceUtil.areEqual(getValues(), other.getValues()) && EquivalenceUtil.areEqual(getVariables(), other.getVariables()) && sameOptionAndHint(other) && EquivalenceUtil.areEqual(getQueryExpression(), other.getQueryExpression()); }