private Insert correctDatatypes(Insert insert) { boolean needsView = false; for (int i = 0; !needsView && i < insert.getVariables().size(); i++) { Expression ses = insert.getVariables().get(i); if (ses.getType() != insert.getQueryExpression().getProjectedSymbols().get(i).getType()) { needsView = true; } } if (needsView) { try { insert.setQueryExpression(createInlineViewQuery(new GroupSymbol("X"), insert.getQueryExpression(), metadata, insert.getVariables())); //$NON-NLS-1$ } catch (TeiidException err) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30371, err); } } return insert; }
private Insert correctDatatypes(Insert insert) { boolean needsView = false; for (int i = 0; !needsView && i < insert.getVariables().size(); i++) { Expression ses = insert.getVariables().get(i); if (ses.getType() != insert.getQueryExpression().getProjectedSymbols().get(i).getType()) { needsView = true; } } if (needsView) { try { insert.setQueryExpression(createInlineViewQuery(new GroupSymbol("X"), insert.getQueryExpression(), metadata, insert.getVariables())); //$NON-NLS-1$ } catch (TeiidException err) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30371, err); } } return insert; }
private Insert correctDatatypes(Insert insert) { boolean needsView = false; for (int i = 0; !needsView && i < insert.getVariables().size(); i++) { Expression ses = insert.getVariables().get(i); if (ses.getType() != insert.getQueryExpression().getProjectedSymbols().get(i).getType()) { needsView = true; } } if (needsView) { try { insert.setQueryExpression(createInlineViewQuery(new GroupSymbol("X"), insert.getQueryExpression(), metadata, insert.getVariables())); //$NON-NLS-1$ } catch (TeiidException err) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30371, err); } } return insert; }
insert.setQueryExpression((QueryCommand)rewriteCommand(insert.getQueryExpression(), true)); return correctDatatypes(insert);
insert.setQueryExpression((QueryCommand)rewriteCommand(insert.getQueryExpression(), true)); return correctDatatypes(insert);
insert.setQueryExpression((QueryCommand)rewriteCommand(insert.getQueryExpression(), true)); return correctDatatypes(insert);
/** * This method will alias each of the select into elements to the corresponding column name in the * target table. This ensures that they will all be uniquely named. * * @param query * @throws QueryValidatorException */ private Command rewriteSelectInto(Query query) throws TeiidProcessingException{ Into into = query.getInto(); try { List<ElementSymbol> allIntoElements = Util.deepClone(ResolverUtil.resolveElementsInGroup(into.getGroup(), metadata), ElementSymbol.class); Insert insert = new Insert(into.getGroup(), allIntoElements, Collections.emptyList()); insert.setSourceHint(query.getSourceHint()); query.setSourceHint(null); query.setInto(null); insert.setQueryExpression(query); return rewriteInsert(correctDatatypes(insert)); } catch (QueryMetadataException e) { throw new QueryValidatorException(e); } catch (TeiidComponentException e) { throw new QueryValidatorException(e); } }
mapped.setQueryExpression(queryExpression); return QueryOptimizer.optimizePlan(mapped, metadata, idGenerator, capFinder, analysisRecord, context);
/** * This method will alias each of the select into elements to the corresponding column name in the * target table. This ensures that they will all be uniquely named. * * @param query * @throws QueryValidatorException */ private Command rewriteSelectInto(Query query) throws TeiidProcessingException{ Into into = query.getInto(); try { List<ElementSymbol> allIntoElements = Util.deepClone(ResolverUtil.resolveElementsInGroup(into.getGroup(), metadata), ElementSymbol.class); Insert insert = new Insert(into.getGroup(), allIntoElements, Collections.emptyList()); insert.setSourceHint(query.getSourceHint()); query.setSourceHint(null); query.setInto(null); insert.setQueryExpression(query); return rewriteInsert(correctDatatypes(insert)); } catch (QueryMetadataException e) { throw new QueryValidatorException(e); } catch (TeiidComponentException e) { throw new QueryValidatorException(e); } }
/** * This method will alias each of the select into elements to the corresponding column name in the * target table. This ensures that they will all be uniquely named. * * @param query * @throws QueryValidatorException */ private Command rewriteSelectInto(Query query) throws TeiidProcessingException{ Into into = query.getInto(); try { List<ElementSymbol> allIntoElements = Util.deepClone(ResolverUtil.resolveElementsInGroup(into.getGroup(), metadata), ElementSymbol.class); Insert insert = new Insert(into.getGroup(), allIntoElements, Collections.emptyList()); insert.setSourceHint(query.getSourceHint()); query.setSourceHint(null); query.setInto(null); insert.setQueryExpression(query); return rewriteInsert(correctDatatypes(insert)); } catch (QueryMetadataException e) { throw new QueryValidatorException(e); } catch (TeiidComponentException e) { throw new QueryValidatorException(e); } }
mapped.setQueryExpression(queryExpression); return QueryOptimizer.optimizePlan(mapped, metadata, idGenerator, capFinder, analysisRecord, context);
/** * Return a deep copy of this Insert. * @return Deep copy of Insert */ public Object clone() { GroupSymbol copyGroup = null; if(group != null) { copyGroup = group.clone(); } List<ElementSymbol> copyVars = LanguageObject.Util.deepClone(getVariables(), ElementSymbol.class); List<Expression> copyVals = null; if ( getValues() != null) { copyVals = LanguageObject.Util.deepClone(getValues(), Expression.class); } Insert copy = new Insert(copyGroup, copyVars, copyVals); if (this.queryExpression != null) { copy.setQueryExpression((QueryCommand)this.queryExpression.clone()); } this.copyMetadataState(copy); if (this.constraint != null) { copy.constraint = (Criteria) this.constraint.clone(); } copy.upsert = this.upsert; return copy; }
/** * Return a deep copy of this Insert. * @return Deep copy of Insert */ public Object clone() { GroupSymbol copyGroup = null; if(group != null) { copyGroup = group.clone(); } List<ElementSymbol> copyVars = LanguageObject.Util.deepClone(getVariables(), ElementSymbol.class); List<Expression> copyVals = null; if ( getValues() != null) { copyVals = LanguageObject.Util.deepClone(getValues(), Expression.class); } Insert copy = new Insert(copyGroup, copyVars, copyVals); if (this.queryExpression != null) { copy.setQueryExpression((QueryCommand)this.queryExpression.clone()); } this.copyMetadataState(copy); if (this.constraint != null) { copy.constraint = (Criteria) this.constraint.clone(); } copy.upsert = this.upsert; return copy; }
/** * Return a deep copy of this Insert. * @return Deep copy of Insert */ public Object clone() { GroupSymbol copyGroup = null; if(group != null) { copyGroup = group.clone(); } List<ElementSymbol> copyVars = LanguageObject.Util.deepClone(getVariables(), ElementSymbol.class); List<Expression> copyVals = null; if ( getValues() != null) { copyVals = LanguageObject.Util.deepClone(getValues(), Expression.class); } Insert copy = new Insert(copyGroup, copyVars, copyVals); if (this.queryExpression != null) { copy.setQueryExpression((QueryCommand)this.queryExpression.clone()); } this.copyMetadataState(copy); if (this.constraint != null) { copy.constraint = (Criteria) this.constraint.clone(); } copy.upsert = this.upsert; return copy; }
insert.setQueryExpression(query); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case OPTION:
insert.setQueryExpression(query); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case OPTION:
insert.setQueryExpression(query); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case OPTION:
@Test public void testInsertIntoSelect() { GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$ From from = new From(); from.addGroup(g); Insert insert = new Insert(); GroupSymbol groupSymbol = new GroupSymbol( "tempA" ); //$NON-NLS-1$ insert.setGroup(groupSymbol); Select select = new Select(); select.addSymbol( new Constant( 1 ) ); //$NON-NLS-1$ Query query = new Query(); query.setSelect(select); insert.setQueryExpression( query ); helpTest("insert into tempA SELECT 1", //$NON-NLS-1$ "INSERT INTO tempA SELECT 1", //$NON-NLS-1$ insert); }
insert.setQueryExpression(query); parent.addStatement(new CommandStatement(insert)); Query q = new Query();
insert.setQueryExpression(query); parent.addStatement(new CommandStatement(insert)); Query q = new Query();