This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch dev-1.0.0 in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit e7233ded231da5898115f5a5545d2ccc121d1f76 Author: Arthur Yang <arthuryan...@users.noreply.github.com> AuthorDate: Thu Feb 24 23:12:51 2022 +0800 [fix](load) Fix InsertStmt prepareExpressions (#8112) Use queryStmt.getResultExprs() instead of queryStmt.getBaseTblResultExprs() in InsertStmt prepareExpressions func. --- .../java/org/apache/doris/analysis/InsertStmt.java | 2 +- .../doris/common/profile/PlanTreeBuilder.java | 7 +++++- .../org/apache/doris/planner/QueryPlanTest.java | 28 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java index dcbc4c0..f750749 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java @@ -667,7 +667,7 @@ public class InsertStmt extends DdlStmt { } public void prepareExpressions() throws UserException { - List<Expr> selectList = Expr.cloneList(queryStmt.getBaseTblResultExprs()); + List<Expr> selectList = Expr.cloneList(queryStmt.getResultExprs()); // check type compatibility int numCols = targetColumns.size(); for (int i = 0; i < numCols; ++i) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/profile/PlanTreeBuilder.java b/fe/fe-core/src/main/java/org/apache/doris/common/profile/PlanTreeBuilder.java index dab18e1..8d8d088 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/profile/PlanTreeBuilder.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/profile/PlanTreeBuilder.java @@ -56,7 +56,12 @@ public class PlanTreeBuilder { PlanTreeNode sinkNode = null; if (sink != null) { StringBuilder sb = new StringBuilder(); - sb.append("[").append(sink.getExchNodeId().asInt()).append(": ").append(sink.getClass().getSimpleName()).append("]"); + if (sink.getExchNodeId() != null) { + sb.append("[").append(sink.getExchNodeId().asInt()).append(": ") + .append(sink.getClass().getSimpleName()).append("]"); + } else { + sb.append("[").append(sink.getClass().getSimpleName()).append("]"); + } sb.append("\n[Fragment: ").append(fragment.getId().asInt()).append("]"); sb.append("\n").append(sink.getExplainString("", TExplainLevel.BRIEF)); sinkNode = new PlanTreeNode(sink.getExchNodeId(), sb.toString()); diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java index dc2206e..94417eb 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java @@ -433,6 +433,20 @@ public class QueryPlanTest { "\"replication_num\" = \"1\"" + ");"); + createTable("CREATE TABLE test.result_exprs (\n" + + " `aid` int(11) NULL,\n" + + " `bid` int(11) NULL\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(`aid`)\n" + + "COMMENT \"OLAP\"\n" + + "DISTRIBUTED BY HASH(`aid`) BUCKETS 7\n" + + "PROPERTIES (\n" + + "\"replication_num\" = \"1\",\n" + + "\"in_memory\" = \"false\",\n" + + "\"business_key_column_name\" = \"\",\n" + + "\"storage_medium\" = \"HDD\",\n" + + "\"storage_format\" = \"V2\"\n" + + ");\n"); } @AfterClass @@ -2026,4 +2040,18 @@ public class QueryPlanTest { } } + @Test + public void testResultExprs() throws Exception { + connectContext.setDatabase("default_cluster:test"); + String queryStr = "EXPLAIN INSERT INTO result_exprs\n" + + "SELECT a.aid,\n" + + " b.bid\n" + + "FROM\n" + + " (SELECT 3 AS aid)a\n" + + "RIGHT JOIN\n" + + " (SELECT 4 AS bid)b ON (a.aid=b.bid)\n"; + String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, queryStr); + Assert.assertFalse(explainString.contains("OUTPUT EXPRS:3 | 4")); + Assert.assertTrue(explainString.contains("OUTPUT EXPRS:CAST(`a`.`aid` AS INT) | 4")); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org