morningman commented on a change in pull request #7865: URL: https://github.com/apache/incubator-doris/pull/7865#discussion_r794547641
########## File path: fe/fe-core/src/test/java/org/apache/doris/planner/TableFunctionPlanTest.java ########## @@ -470,4 +478,55 @@ public void aggColumnInOuterQuery() throws Exception { Assert.assertTrue(explainString.contains("output slot id: 2")); Assert.assertTrue(explainString.contains("tuple ids: 1 3")); } + + @Test + public void testLaterViewWithView() throws Exception { + // test 1 + String createViewStr = "create view db1.v1 (k1,e1) as select k1,e1 from db1.table_for_view lateral view explode_split(k3,',') tmp as e1;"; + CreateViewStmt createViewStmt = (CreateViewStmt) UtFrameUtils.parseAndAnalyzeStmt(createViewStr, ctx); + Catalog.getCurrentCatalog().createView(createViewStmt); + + String sql = "select * from db1.v1;"; + String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql, true); + Assert.assertTrue(explainString.contains("output slot id: 1 2")); + // query again to see if it has error + explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql, true); + Assert.assertTrue(explainString.contains("output slot id: 1 2")); + } + + @Test + public void testLaterViewWithWhere() throws Exception { + String sql = "select k1,e1 from db1.table_for_view lateral view explode_split(k3,',') tmp as e1 where k1 in (select k2 from db1.table_for_view);"; + String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql, true); + Assert.assertTrue(explainString.contains("join op: LEFT SEMI JOIN (BROADCAST)")); + Assert.assertTrue(explainString.contains("equal join conjunct: `k1` = `k2`")); + Assert.assertTrue(!explainString.contains("equal join conjunct: `k2` = `k2`")); + } + + @Test + public void testLaterViewWithCTE() throws Exception { + String sql = "with tmp as (select k1,e1 from db1.table_for_view lateral view explode_split(k3,',') tmp2 as e1) select * from tmp;"; + String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql, true); + Assert.assertTrue(explainString.contains("table function: explode_split(`default_cluster:db1`.`table_for_view`.`k3`, ',') ")); + } + + @Ignore + // errCode = 2, detailMessage = Unknown column 'e1' in 'table list' + public void testLaterViewWithCTEBug() throws Exception { + String sql = "with tmp as (select * from db1.table_for_view where k2=1) select k1,e1 from tmp lateral view explode_split(k3,',') tmp2 as e1;"; + String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql, true); + Assert.assertTrue(!explainString.contains("Unknown column 'e1' in 'table list'")); + } + + @Ignore + // errCode = 2, detailMessage = Unknown column 'e1' in 'table list' + public void testLaterViewUnknowColumnBug() throws Exception { Review comment: I leaves to you to fix it. LOL -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org