private void setProjectedTypes(SetQuery setQuery, List<Class<?>> firstProjectTypes, QueryMetadataInterface metadata) throws QueryResolverException { for (QueryCommand subCommand : setQuery.getQueryCommands()) { if (!(subCommand instanceof SetQuery)) { continue; } SetQuery child = (SetQuery)subCommand; List projectedSymbols = child.getProjectedSymbols(); if (child.getOrderBy() != null) { for (int j = 0; j < projectedSymbols.size(); j++) { Expression ses = (Expression)projectedSymbols.get(j); Class<?> targetType = firstProjectTypes.get(j); if (ses.getType() != targetType && orderByContainsVariable(child.getOrderBy(), ses, j)) { String sourceTypeName = DataTypeManager.getDataTypeName(ses.getType()); String targetTypeName = DataTypeManager.getDataTypeName(targetType); throw new QueryResolverException(QueryPlugin.Util.getString("UnionQueryResolver.type_conversion", //$NON-NLS-1$ new Object[] {ses, sourceTypeName, targetTypeName})); } } } child.setProjectedTypes(firstProjectTypes, metadata); setProjectedTypes(child, firstProjectTypes, metadata); } }
private void setProjectedTypes(SetQuery setQuery, List<Class<?>> firstProjectTypes, QueryMetadataInterface metadata) throws QueryResolverException { for (QueryCommand subCommand : setQuery.getQueryCommands()) { if (!(subCommand instanceof SetQuery)) { continue; } SetQuery child = (SetQuery)subCommand; List projectedSymbols = child.getProjectedSymbols(); if (child.getOrderBy() != null) { for (int j = 0; j < projectedSymbols.size(); j++) { Expression ses = (Expression)projectedSymbols.get(j); Class<?> targetType = firstProjectTypes.get(j); if (ses.getType() != targetType && orderByContainsVariable(child.getOrderBy(), ses, j)) { String sourceTypeName = DataTypeManager.getDataTypeName(ses.getType()); String targetTypeName = DataTypeManager.getDataTypeName(targetType); throw new QueryResolverException(QueryPlugin.Util.getString("UnionQueryResolver.type_conversion", //$NON-NLS-1$ new Object[] {ses, sourceTypeName, targetTypeName})); } } } child.setProjectedTypes(firstProjectTypes, metadata); setProjectedTypes(child, firstProjectTypes, metadata); } }
private void setProjectedTypes(SetQuery setQuery, List<Class<?>> firstProjectTypes, QueryMetadataInterface metadata) throws QueryResolverException { for (QueryCommand subCommand : setQuery.getQueryCommands()) { if (!(subCommand instanceof SetQuery)) { continue; } SetQuery child = (SetQuery)subCommand; List projectedSymbols = child.getProjectedSymbols(); if (child.getOrderBy() != null) { for (int j = 0; j < projectedSymbols.size(); j++) { Expression ses = (Expression)projectedSymbols.get(j); Class<?> targetType = firstProjectTypes.get(j); if (ses.getType() != targetType && orderByContainsVariable(child.getOrderBy(), ses, j)) { String sourceTypeName = DataTypeManager.getDataTypeName(ses.getType()); String targetTypeName = DataTypeManager.getDataTypeName(targetType); throw new QueryResolverException(QueryPlugin.Util.getString("UnionQueryResolver.type_conversion", //$NON-NLS-1$ new Object[] {ses, sourceTypeName, targetTypeName})); } } } child.setProjectedTypes(firstProjectTypes, metadata); setProjectedTypes(child, firstProjectTypes, metadata); } }
public static boolean extractQueries(QueryCommand queryCommand, List<Query> result) { if (queryCommand instanceof SetQuery) { SetQuery sq = (SetQuery)queryCommand; if (sq.isAll() && sq.getOperation() == Operation.UNION && sq.getOrderBy() == null && sq.getLimit() == null && sq.getWith() == null) { if (!extractQueries(sq.getLeftQuery(), result)) { return false; } if (!extractQueries(sq.getRightQuery(), result)) { return false; } return true; } return false; } result.add((Query)queryCommand); return true; }
public static boolean extractQueries(QueryCommand queryCommand, List<Query> result) { if (queryCommand instanceof SetQuery) { SetQuery sq = (SetQuery)queryCommand; if (sq.isAll() && sq.getOperation() == Operation.UNION && sq.getOrderBy() == null && sq.getLimit() == null && sq.getWith() == null) { if (!extractQueries(sq.getLeftQuery(), result)) { return false; } if (!extractQueries(sq.getRightQuery(), result)) { return false; } return true; } return false; } result.add((Query)queryCommand); return true; }
public static boolean extractQueries(QueryCommand queryCommand, List<Query> result) { if (queryCommand instanceof SetQuery) { SetQuery sq = (SetQuery)queryCommand; if (sq.isAll() && sq.getOperation() == Operation.UNION && sq.getOrderBy() == null && sq.getLimit() == null && sq.getWith() == null) { if (!extractQueries(sq.getLeftQuery(), result)) { return false; } if (!extractQueries(sq.getRightQuery(), result)) { return false; } return true; } return false; } result.add((Query)queryCommand); return true; }
/** * visit the branches other than the first with individual naming contexts * Aliases are being added in all cases, even though they may only be needed in the order by case. * Adding the same alias to all branches ensures cross db support (db2 in particular) */ public void visit(SetQuery obj) { visitor.createChildNamingContext(true); visitNode(obj.getRightQuery()); visitor.removeChildNamingContext(); visitor.namingContext.aliasColumns = true; visitNode(obj.getLeftQuery()); visitNode(obj.getOrderBy()); }
/** * visit the branches other than the first with individual naming contexts * Aliases are being added in all cases, even though they may only be needed in the order by case. * Adding the same alias to all branches ensures cross db support (db2 in particular) */ public void visit(SetQuery obj) { visitor.createChildNamingContext(true); visitNode(obj.getRightQuery()); visitor.removeChildNamingContext(); visitor.namingContext.aliasColumns = true; visitNode(obj.getLeftQuery()); visitNode(obj.getOrderBy()); }
/** * visit the branches other than the first with individual naming contexts * Aliases are being added in all cases, even though they may only be needed in the order by case. * Adding the same alias to all branches ensures cross db support (db2 in particular) */ public void visit(SetQuery obj) { visitor.createChildNamingContext(true); visitNode(obj.getRightQuery()); visitor.removeChildNamingContext(); visitor.namingContext.aliasColumns = true; visitNode(obj.getLeftQuery()); visitNode(obj.getOrderBy()); }
/** * 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; }
/** * Compare two queries for equality. * @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 SetQuery)) { return false; } SetQuery other = (SetQuery) obj; return getOperation() == other.getOperation() && EquivalenceUtil.areEqual(this.isAll(), other.isAll()) && EquivalenceUtil.areEqual(this.leftQuery, other.leftQuery) && EquivalenceUtil.areEqual(this.rightQuery, other.rightQuery) && EquivalenceUtil.areEqual(getOrderBy(), other.getOrderBy()) && EquivalenceUtil.areEqual(getLimit(), other.getLimit()) && EquivalenceUtil.areEqual(getWith(), other.getWith()) && sameOptionAndHint(other); }
public void visit(SetQuery obj) { preVisitVisitor(obj); visitNodes(obj.getWith()); visitNodes(obj.getQueryCommands()); visitNode(obj.getOrderBy()); visitNode(obj.getLimit()); visitNode(obj.getOption()); postVisitVisitor(obj); }
public void visit(SetQuery obj) { preVisitVisitor(obj); visitNodes(obj.getWith()); visitNodes(obj.getQueryCommands()); visitNode(obj.getOrderBy()); visitNode(obj.getLimit()); visitNode(obj.getOption()); postVisitVisitor(obj); }
public void visit(SetQuery obj) { preVisitVisitor(obj); visitNodes(obj.getWith()); visitNodes(obj.getQueryCommands()); visitNode(obj.getOrderBy()); visitNode(obj.getLimit()); visitNode(obj.getOption()); postVisitVisitor(obj); }
@Override public void visit( SetQuery obj ) { addCacheHint(obj.getCacheHint()); addWithClause(obj); QueryCommand query = obj.getLeftQuery(); appendSetQuery(obj, query, false); beginClause(0); append(obj.getOperation()); if (obj.isAll()) { append(SPACE); append(ALL); } beginClause(0); query = obj.getRightQuery(); appendSetQuery(obj, query, true); if (obj.getOrderBy() != null) { beginClause(0); visitNode(obj.getOrderBy()); } if (obj.getLimit() != null) { beginClause(0); visitNode(obj.getLimit()); } if (obj.getOption() != null) { beginClause(0); visitNode(obj.getOption()); } }
org.teiid.language.SetQuery translate(SetQuery union) { org.teiid.language.SetQuery result = new org.teiid.language.SetQuery(); result.setWith(translate(union.getWith())); result.setAll(union.isAll()); switch (union.getOperation()) { case UNION: result.setOperation(org.teiid.language.SetQuery.Operation.UNION); break; case INTERSECT: result.setOperation(org.teiid.language.SetQuery.Operation.INTERSECT); break; case EXCEPT: result.setOperation(org.teiid.language.SetQuery.Operation.EXCEPT); break; } result.setLeftQuery(translate(union.getLeftQuery())); result.setRightQuery(translate(union.getRightQuery())); result.setOrderBy(translate(union.getOrderBy(), true)); result.setLimit(translate(union.getLimit())); return result; }
org.teiid.language.SetQuery translate(SetQuery union) { org.teiid.language.SetQuery result = new org.teiid.language.SetQuery(); result.setWith(translate(union.getWith())); result.setAll(union.isAll()); switch (union.getOperation()) { case UNION: result.setOperation(org.teiid.language.SetQuery.Operation.UNION); break; case INTERSECT: result.setOperation(org.teiid.language.SetQuery.Operation.INTERSECT); break; case EXCEPT: result.setOperation(org.teiid.language.SetQuery.Operation.EXCEPT); break; } result.setLeftQuery(translate(union.getLeftQuery())); result.setRightQuery(translate(union.getRightQuery())); result.setOrderBy(translate(union.getOrderBy(), true)); result.setLimit(translate(union.getLimit())); return result; }
org.teiid.language.SetQuery translate(SetQuery union) { org.teiid.language.SetQuery result = new org.teiid.language.SetQuery(); result.setWith(translate(union.getWith())); result.setAll(union.isAll()); switch (union.getOperation()) { case UNION: result.setOperation(org.teiid.language.SetQuery.Operation.UNION); break; case INTERSECT: result.setOperation(org.teiid.language.SetQuery.Operation.INTERSECT); break; case EXCEPT: result.setOperation(org.teiid.language.SetQuery.Operation.EXCEPT); break; } result.setLeftQuery(translate(union.getLeftQuery())); result.setRightQuery(translate(union.getRightQuery())); result.setOrderBy(translate(union.getOrderBy(), true)); result.setLimit(translate(union.getLimit())); return result; }