@Test public void testDynamicRecursion() throws Exception { TransformationMetadata metadata = TestUpdateValidator.example1(); TestUpdateValidator.createView("select 'a' as x, 2 as y", metadata, GX); Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX); t.setDeletePlan("FOR EACH ROW BEGIN ATOMIC insert into gx (x, y) values (old.x, old.y); END"); t.setUpdatePlan(""); t.setInsertPlan("FOR EACH ROW BEGIN execute immediate 'delete from gx where gx.x = new.x'; END"); String sql = "insert into gx (x, y) select e1, e2 from pm1.g1"; FakeDataManager dm = new FakeDataManager(); FakeDataStore.addTable("pm1.g1", dm, metadata); CommandContext context = createCommandContext(); BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); ProcessorPlan plan = TestProcessor.helpGetPlan(TestResolver.helpResolve(sql, metadata), metadata, new DefaultCapabilitiesFinder(caps), context); try { helpProcess(plan, context, dm, null); fail(); } catch (QueryProcessingException e) { assertEquals("TEIID30168 Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'delete from gx where gx.x = new.x'\" with the SQL statement \"delete from gx where gx.x = new.x\" due to: TEIID30347 There is a recursive invocation of group 'I gx'. Please correct the SQL.", e.getMessage()); } }