This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 40805f2e4fc branch-3.0: [fix](nereids)fix the
cascadesContext.getMemo()==null #48771 (#49094)
40805f2e4fc is described below
commit 40805f2e4fc252a63a638da0e1fe991f73d4a0f0
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Mar 15 10:08:31 2025 +0800
branch-3.0: [fix](nereids)fix the cascadesContext.getMemo()==null #48771
(#49094)
Cherry-picked from #48771
Co-authored-by: zhangm365 <[email protected]>
---
.../org/apache/doris/nereids/NereidsPlanner.java | 15 ++++--
.../test_insert_table_with_dump_nereids_memo.out | Bin 0 -> 126 bytes
...test_insert_table_with_dump_nereids_memo.groovy | 58 +++++++++++++++++++++
3 files changed, 70 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
index 2425079bdb4..885a32c70b2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
@@ -268,8 +268,12 @@ public class NereidsPlanner extends Planner {
// print memo before choose plan.
// if chooseNthPlan failed, we could get memo to debug
if
(cascadesContext.getConnectContext().getSessionVariable().dumpNereidsMemo) {
- String memo = cascadesContext.getMemo().toString();
- LOG.info("{}\n{}", ConnectContext.get().getQueryIdentifier(),
memo);
+ Memo memo = cascadesContext.getMemo();
+ if (memo != null) {
+ LOG.info("{}\n{}", ConnectContext.get().getQueryIdentifier(),
memo.toString());
+ } else {
+ LOG.info("{}\nMemo is null",
ConnectContext.get().getQueryIdentifier());
+ }
}
int nth =
cascadesContext.getConnectContext().getSessionVariable().getNthOptimizedPlan();
PhysicalPlan physicalPlan = chooseNthPlan(getRoot(),
requireProperties, nth);
@@ -674,10 +678,15 @@ public class NereidsPlanner extends Planner {
plan = optimizedPlan.shape("");
break;
case MEMO_PLAN:
- plan = cascadesContext.getMemo().toString()
+ Memo memo = cascadesContext.getMemo();
+ if (memo == null) {
+ plan = "Memo is null";
+ } else {
+ plan = memo.toString()
+ "\n\n========== OPTIMIZED PLAN ==========\n"
+ optimizedPlan.treeString()
+ mvSummary;
+ }
break;
case DISTRIBUTED_PLAN:
StringBuilder distributedPlanStringBuilder = new
StringBuilder();
diff --git
a/regression-test/data/correctness/test_insert_table_with_dump_nereids_memo.out
b/regression-test/data/correctness/test_insert_table_with_dump_nereids_memo.out
new file mode 100644
index 00000000000..a8291e75384
Binary files /dev/null and
b/regression-test/data/correctness/test_insert_table_with_dump_nereids_memo.out
differ
diff --git
a/regression-test/suites/correctness/test_insert_table_with_dump_nereids_memo.groovy
b/regression-test/suites/correctness/test_insert_table_with_dump_nereids_memo.groovy
new file mode 100644
index 00000000000..a51aba93a5a
--- /dev/null
+++
b/regression-test/suites/correctness/test_insert_table_with_dump_nereids_memo.groovy
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_insert_table_with_dump_nereids_memo") {
+
+ def testTable = "test_insert_table_with_dump_nereids_memo"
+ // Clean up any existing table with the same name
+ sql "DROP TABLE IF EXISTS ${testTable}"
+
+ // Create table with with test 'dump_nereids_memo' SessionVariable
+ // set dump_nereids_memo to true
+ sql "set dump_nereids_memo = true"
+
+ // Verify that the variable is set correctly
+ def result = sql "SHOW VARIABLES LIKE 'dump_nereids_memo'"
+ assertTrue(result[0][1] == "true")
+
+ sql """
+ CREATE TABLE ${testTable}
+ (
+ id int,
+ name string
+ )
+ COMMENT "test table with dump_nereids_memo"
+ DISTRIBUTED BY HASH(id) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1"
+ )
+ """
+
+ // Insert data into the table
+ sql "INSERT INTO ${testTable} VALUES (1, 'hello'), (2, 'world')"
+
+ // Synchronize to ensure data is visible
+ sql "SYNC"
+
+ // Verify that data was inserted correctly
+ qt_select "SELECT * FROM ${testTable} ORDER BY id"
+
+ // Clean up after the test
+ sql "DROP TABLE IF EXISTS ${testTable}"
+ sql "set dump_nereids_memo = false"
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]