Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ public InlineViewRef(View view, TableRef origTblRef) {
// TODO(zc)
// view_.getTableName().toString().toLowerCase(), view.getName().toLowerCase()
if (view.isLocalView()) {
aliases_ = new String[] { view.getName() };
aliases_ = new String[]{view.getName()};
} else {
aliases_ = new String[] { name.toString(), view.getName() };
aliases_ = new String[]{name.toString(), view.getName()};
}
if (origTblRef.getLateralViewRefs() != null) {
lateralViewRefs = (ArrayList<LateralViewRef>) origTblRef.getLateralViewRefs().clone();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public void aggColumnInOuterQuery() throws Exception {
}

@Test
public void testLaterViewWithView() throws Exception {
public void testLateralViewWithView() 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);
Expand All @@ -495,7 +495,7 @@ public void testLaterViewWithView() throws Exception {
}

@Test
public void testLaterViewWithWhere() throws Exception {
public void testLateralViewWithWhere() 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)"));
Expand All @@ -504,23 +504,21 @@ public void testLaterViewWithWhere() throws Exception {
}

@Test
public void testLaterViewWithCTE() throws Exception {
public void testLateralViewWithCTE() 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 {
@Test
public void testLateralViewWithCTEBug() 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 {
@Test
public void testLateralViewUnknownColumnBug() throws Exception {
// test2
String createViewStr = "create view db1.v2 (k1,k3) as select k1,k3 from db1.table_for_view;";
CreateViewStmt createViewStmt = (CreateViewStmt) UtFrameUtils.parseAndAnalyzeStmt(createViewStr, ctx);
Expand Down