teiid SVN: r4616 - in branches/7.7.x/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2013-11-20 16:21:24 -0500 (Wed, 20 Nov 2013)
New Revision: 4616
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
Log:
TEIID-2745: Evaluatable subquery in ON clause produces invalid query
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2013-11-12 14:43:16 UTC (rev 4615)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2013-11-20 21:21:24 UTC (rev 4616)
@@ -889,8 +889,8 @@
if(joinCrits != null && joinCrits.size() > 0) {
//rewrite join crits by rewriting a compound criteria
Criteria criteria = new CompoundCriteria(new ArrayList(joinCrits));
+ criteria = rewriteCriteria(criteria);
joinCrits.clear();
- criteria = rewriteCriteria(criteria);
if (criteria instanceof CompoundCriteria && ((CompoundCriteria)criteria).getOperator() == CompoundCriteria.AND) {
joinCrits.addAll(((CompoundCriteria)criteria).getCriteria());
} else {
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2013-11-12 14:43:16 UTC (rev 4615)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2013-11-20 21:21:24 UTC (rev 4616)
@@ -253,4 +253,36 @@
helpProcess(plan, dataManager, result);
}
+
+ @Test public void testSingleItemInOn() {
+ String sql = "with a (x, y, z) as (select e1, e2, e3 from pm1.g1 limit 1) SELECT pm2.g1.e1 from pm2.g1 left outer join pm2.g2 on (pm2.g1.e2 = pm2.g2.e2 and pm2.g1.e1 = (select a.x from a))"; //$NON-NLS-1$
+
+ List[] expected = new List[] {Arrays.asList("a")};
+
+ HardcodedDataManager dataManager = new HardcodedDataManager() {
+
+ boolean block = true;
+
+ @Override
+ public TupleSource registerRequest(CommandContext context,
+ Command command, String modelName, String connectorBindingId, int nodeID, int limit)
+ throws TeiidComponentException {
+ if (block) {
+ block = false;
+ throw BlockedException.INSTANCE;
+ }
+ return super.registerRequest(context, command, modelName, null, 0, 0);
+ }
+ };
+ dataManager.addData("SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0", new List[] {Arrays.asList("a", 1, true)});
+ dataManager.addData("SELECT g_0.e1 FROM pm2.g1 AS g_0 LEFT OUTER JOIN pm2.g2 AS g_1 ON g_0.e2 = g_1.e2 AND g_0.e1 = 'a'", new List[] {Arrays.asList("a")});
+
+ BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
+ bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ bsc.setCapabilitySupport(Capability.CRITERIA_ON_SUBQUERY, true);
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(bsc));
+
+ helpProcess(plan, dataManager, expected);
+ }
+
}