@Test public void testUnionWithLimit(){ SetQuery setQuery = exampleSetQuery(Operation.UNION); setQuery.setLimit(new Limit(null, new Constant(1))); TestParser.helpTest("SELECT a FROM g UNION select b from h LIMIT 1", //$NON-NLS-1$ "SELECT a FROM g UNION SELECT b FROM h LIMIT 1", //$NON-NLS-1$ setQuery); }
/** * Deep clone this object to produce a new identical query. * @return Deep clone */ public Object clone() { SetQuery copy = new SetQuery(this.operation); this.copyMetadataState(copy); copy.leftQuery = (QueryCommand)this.leftQuery.clone(); copy.rightQuery = (QueryCommand)this.rightQuery.clone(); copy.setAll(this.all); if(this.getOrderBy() != null) { copy.setOrderBy(this.getOrderBy().clone()); } if(this.getLimit() != null) { copy.setLimit( (Limit) this.getLimit().clone() ); } copy.setWith(LanguageObject.Util.deepClone(this.getWith(), WithQueryCommand.class)); if (this.projectedTypes != null) { copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes), this.metadata); } return copy; }
/** * Deep clone this object to produce a new identical query. * @return Deep clone */ public Object clone() { SetQuery copy = new SetQuery(this.operation); this.copyMetadataState(copy); copy.leftQuery = (QueryCommand)this.leftQuery.clone(); copy.rightQuery = (QueryCommand)this.rightQuery.clone(); copy.setAll(this.all); if(this.getOrderBy() != null) { copy.setOrderBy(this.getOrderBy().clone()); } if(this.getLimit() != null) { copy.setLimit( (Limit) this.getLimit().clone() ); } copy.setWith(LanguageObject.Util.deepClone(this.getWith(), WithQueryCommand.class)); if (this.projectedTypes != null) { copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes), this.metadata); } return copy; }
/** * Deep clone this object to produce a new identical query. * @return Deep clone */ public Object clone() { SetQuery copy = new SetQuery(this.operation); this.copyMetadataState(copy); copy.leftQuery = (QueryCommand)this.leftQuery.clone(); copy.rightQuery = (QueryCommand)this.rightQuery.clone(); copy.setAll(this.all); if(this.getOrderBy() != null) { copy.setOrderBy(this.getOrderBy().clone()); } if(this.getLimit() != null) { copy.setLimit( (Limit) this.getLimit().clone() ); } copy.setWith(LanguageObject.Util.deepClone(this.getWith(), WithQueryCommand.class)); if (this.projectedTypes != null) { copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes), this.metadata); } return copy; }
private SetQuery rewriteSetQuery(SetQuery setQuery) throws TeiidComponentException, TeiidProcessingException{ if (setQuery.getProjectedTypes() != null) { for (QueryCommand command : setQuery.getQueryCommands()) { if (!(command instanceof Query)) { continue; } correctProjectedTypes(setQuery.getProjectedTypes(), (Query)command); } setQuery.setProjectedTypes(null, null); } setQuery.setLeftQuery((QueryCommand)rewriteCommand(setQuery.getLeftQuery(), true)); setQuery.setRightQuery((QueryCommand)rewriteCommand(setQuery.getRightQuery(), true)); rewriteOrderBy(setQuery); if (setQuery.getLimit() != null) { setQuery.setLimit(rewriteLimitClause(setQuery.getLimit())); } return setQuery; }
private SetQuery rewriteSetQuery(SetQuery setQuery) throws TeiidComponentException, TeiidProcessingException{ if (setQuery.getProjectedTypes() != null) { for (QueryCommand command : setQuery.getQueryCommands()) { if (!(command instanceof Query)) { continue; } correctProjectedTypes(setQuery.getProjectedTypes(), (Query)command); } setQuery.setProjectedTypes(null, null); } setQuery.setLeftQuery((QueryCommand)rewriteCommand(setQuery.getLeftQuery(), true)); setQuery.setRightQuery((QueryCommand)rewriteCommand(setQuery.getRightQuery(), true)); rewriteOrderBy(setQuery); if (setQuery.getLimit() != null) { setQuery.setLimit(rewriteLimitClause(setQuery.getLimit())); } return setQuery; }
private SetQuery rewriteSetQuery(SetQuery setQuery) throws TeiidComponentException, TeiidProcessingException{ if (setQuery.getProjectedTypes() != null) { for (QueryCommand command : setQuery.getQueryCommands()) { if (!(command instanceof Query)) { continue; } correctProjectedTypes(setQuery.getProjectedTypes(), (Query)command); } setQuery.setProjectedTypes(null, null); } setQuery.setLeftQuery((QueryCommand)rewriteCommand(setQuery.getLeftQuery(), true)); setQuery.setRightQuery((QueryCommand)rewriteCommand(setQuery.getRightQuery(), true)); rewriteOrderBy(setQuery); if (setQuery.getLimit() != null) { setQuery.setLimit(rewriteLimitClause(setQuery.getLimit())); } return setQuery; }
@Test public void testSetQueryLimit() { Query query = new Query(); Select select = new Select(Arrays.asList(new MultipleElementSymbol())); From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$ query.setSelect(select); query.setFrom(from); SetQuery setQuery = new SetQuery(Operation.UNION, true, query, query); setQuery.setLimit(new Limit(new Reference(0), new Reference(1))); helpTest("Select * from a union all Select * from a limit ?,?", "SELECT * FROM a UNION ALL SELECT * FROM a LIMIT ?, ?", setQuery); //$NON-NLS-1$ //$NON-NLS-2$ }