diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/ast/InsertStmt.java b/fe/fe-core/src/main/java/com/starrocks/sql/ast/InsertStmt.java index 8388264764634..8468779a81e08 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/ast/InsertStmt.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/ast/InsertStmt.java @@ -314,7 +314,12 @@ private List collectSelectedFieldsFromQueryStatement() { } public Table makeBlackHoleTable() { - return new BlackHoleTable(collectSelectedFieldsFromQueryStatement()); + List columns = collectSelectedFieldsFromQueryStatement(); + // rename each column's name, assign unique name + for (int i = 0; i < columns.size(); i++) { + columns.get(i).setName(columns.get(i).getName() + "_blackhole_" + i); + } + return new BlackHoleTable(columns); } public Table makeTableFunctionTable(SessionVariable sessionVariable) { diff --git a/fe/fe-core/src/test/java/com/starrocks/sql/plan/DataCachePlanTest.java b/fe/fe-core/src/test/java/com/starrocks/sql/plan/DataCachePlanTest.java index a1f6a676b67af..70aeace789d3c 100644 --- a/fe/fe-core/src/test/java/com/starrocks/sql/plan/DataCachePlanTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/sql/plan/DataCachePlanTest.java @@ -175,5 +175,9 @@ public void testBlackHoleTableSink() throws Exception { String sql = "insert into blackhole() select * from hive0.datacache_db.multi_partition_table " + "where l_shipdate>='1998-01-03'"; assertPlanContains(sql, "BLACKHOLE TABLE SINK"); + + sql = "insert into blackhole() select * from hive0.datacache_db.multi_partition_table join " + + "hive0.datacache_db.multi_partition_table as t"; + assertPlanContains(sql, "BLACKHOLE TABLE SINK"); } }