Skip to content

Commit

Permalink
TEIID-5001 preventing view removal
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Jul 19, 2017
1 parent 79e3fcf commit 0535a6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Expand Up @@ -181,8 +181,15 @@ static PlanNode doMerge(PlanNode frame,
return root; //cannot remove if the no source side is an outer side, or if it can change the meaning of the plan
}
PlanNode other = isLeft? FrameUtil.findJoinSourceNode(parentJoin.getLastChild()):left;
if (other != null && (SymbolMap)other.getProperty(NodeConstants.Info.CORRELATED_REFERENCES) != null) {
return root; //TODO: we don't have the logic yet to then replace the correlated references
if (other != null) {
//scan all sources under the other side as there could be a join structure
for (PlanNode node : NodeEditor.findAllNodes(other, NodeConstants.Types.SOURCE, NodeConstants.Types.SOURCE)) {
SymbolMap map = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
if (map != null) {
//TODO: we don't have the logic yet to then replace the correlated references
return root;
}
}
}
}
}
Expand Down
Expand Up @@ -2570,6 +2570,19 @@ private QueryMetadataInterface createProcedureMetadata(String procedure) {
helpTestProcess(plan, expected, dataManager, tm);
}

@Test public void testTeiid5001() throws Exception {
String sql = "SELECT d.id FROM ( SELECT 'l1' as domain ) dim_md_domains_to_load, table(CALL testcase.proc_web_avg_visit_duration_empty(\"domain\" => domain)) x JOIN testcase.dim_md_date_ranges d ON true";

TransformationMetadata tm = RealMetadataFactory.fromDDL("CREATE VIEW testcase.dim_md_date_ranges AS SELECT 1 as \"id\" union all select 2 "
+ "CREATE VIRTUAL PROCEDURE proc_web_avg_visit_duration_empty( domain string ) RETURNS (i integer) AS BEGIN select 1; END", "x", "testcase");

ProcessorPlan plan = getProcedurePlan(sql, tm);

HardcodedDataManager dataManager = new HardcodedDataManager(tm);
List[] expected = new List[] { Arrays.asList(1), Arrays.asList(2) }; //$NON-NLS-1$
helpTestProcess(plan, expected, dataManager, tm);
}

private static final boolean DEBUG = false;

}

0 comments on commit 0535a6d

Please sign in to comment.