Skip to content

Commit

Permalink
TEIID-5532 fix for inappropriate projection minimization
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Nov 8, 2018
1 parent b6a6c1b commit 6659110
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Expand Up @@ -210,7 +210,9 @@ public RelationalPlan optimize(
// don't fully plan the subqueries as that needs to happen after
// with planning
connectSubqueryContainers(plan, true);
planWith(plan, command);
//use the original to plan with as the command object may have been modified
//in particular the replacement of aggregate expressions
planWith(plan, original);
}
// Connect ProcessorPlan to SubqueryContainer (if any) of SELECT, PROJECT, and other nodes
connectSubqueryContainers(plan, false); //TODO: merge with node creation
Expand Down
Expand Up @@ -15,6 +15,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.ArrayImpl;
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.query.metadata.TransformationMetadata;
Expand Down Expand Up @@ -1048,6 +1049,22 @@ public TupleSource registerRequest(CommandContext context,
TestProcessor.helpProcess(plan, hdm, new List<?>[] {Arrays.asList("a")});
}

@Test public void testUseInProjectedSubquery() throws Exception {
CommandContext cc = TestProcessor.createCommandContext();
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();

TransformationMetadata metadata = RealMetadataFactory.example1Cached();

String sql = "with CTE1 as /*+ no_inline */ (SELECT e1, e2, e3 from pm1.g1) "
+ "select array_agg((select e3 from cte1 where e1=pm1.g2.e1 and e2=pm1.g2.e2)) from pm1.g2";

ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(bsc), cc);
HardcodedDataManager hdm = new HardcodedDataManager(metadata);
hdm.addData("SELECT g_0.e1, g_0.e2 FROM g2 AS g_0", Arrays.asList("a", 1));
hdm.addData("SELECT g_0.e1, g_0.e2, g_0.e3 FROM g1 AS g_0", Arrays.asList("a", 1, true));
TestProcessor.helpProcess(plan, hdm, new List<?>[] {Arrays.asList(new ArrayImpl(true))});
}

@Test public void testNestedSubqueryPreeval() throws Exception {
CommandContext cc = TestProcessor.createCommandContext();
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
Expand Down

0 comments on commit 6659110

Please sign in to comment.