This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 48353d6e8dc [enhance](query)Schema ScanNode supports explain (#46288)
48353d6e8dc is described below
commit 48353d6e8dc4d1a3340a6a12096b4d81c30663e7
Author: zhangdong <[email protected]>
AuthorDate: Mon Jan 6 14:42:22 2025 +0800
[enhance](query)Schema ScanNode supports explain (#46288)
### What problem does this PR solve?
explain select * from user_privileges where IS_GRANTABLE='NO';
| 0:VSCAN SCHEMA(71) |
| TABLE: information_schema.user_privileges |
| PREDICATES: (IS_GRANTABLE[#3] = 'NO') |
| cardinality=-1, avgRowSize=0.0, numNodes=0 |
---
.../org/apache/doris/planner/SchemaScanNode.java | 21 ++++++++++++++++++++
.../system/test_explain_information_schema.groovy | 23 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/SchemaScanNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/SchemaScanNode.java
index 741f765facd..301e81bcd40 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SchemaScanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SchemaScanNode.java
@@ -18,6 +18,7 @@
package org.apache.doris.planner;
import org.apache.doris.analysis.Analyzer;
+import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.TupleDescriptor;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.SchemaTable;
@@ -29,6 +30,7 @@ import org.apache.doris.qe.ConnectContext;
import org.apache.doris.service.FrontendOptions;
import org.apache.doris.statistics.StatisticalType;
import org.apache.doris.system.Frontend;
+import org.apache.doris.thrift.TExplainLevel;
import org.apache.doris.thrift.TNetworkAddress;
import org.apache.doris.thrift.TPlanNode;
import org.apache.doris.thrift.TPlanNodeType;
@@ -166,4 +168,23 @@ public class SchemaScanNode extends ScanNode {
public int getNumInstances() {
return 1;
}
+
+ @Override
+ public String getNodeExplainString(String prefix, TExplainLevel
detailLevel) {
+ StringBuilder output = new StringBuilder();
+ output.append(prefix).append("TABLE:
").append(getSchemaDb()).append(".").append(getTableName());
+ output.append("\n");
+ if (!conjuncts.isEmpty()) {
+ Expr expr = convertConjunctsToAndCompoundPredicate(conjuncts);
+ output.append(prefix).append("PREDICATES:
").append(expr.toSql()).append("\n");
+ }
+ if (!runtimeFilters.isEmpty()) {
+ output.append(prefix).append("runtime filters: ");
+ output.append(getRuntimeFilterExplainString(false));
+ }
+ output.append(prefix).append(String.format("cardinality=%s",
cardinality))
+ .append(String.format(", avgRowSize=%s",
avgRowSize)).append(String.format(", numNodes=%s", numNodes));
+ output.append("\n");
+ return output.toString();
+ }
}
diff --git
a/regression-test/suites/nereids_p0/system/test_explain_information_schema.groovy
b/regression-test/suites/nereids_p0/system/test_explain_information_schema.groovy
new file mode 100644
index 00000000000..0ecbb35a179
--- /dev/null
+++
b/regression-test/suites/nereids_p0/system/test_explain_information_schema.groovy
@@ -0,0 +1,23 @@
+// 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_explain_information_schema", "query,p0") {
+ def explainRes = sql """explain select * from
information_schema.user_privileges where IS_GRANTABLE='NO';"""
+ logger.info("explainRes: " + explainRes.toString())
+ assertTrue(explainRes.toString().contains("PREDICATES"))
+ assertTrue(explainRes.toString().contains("IS_GRANTABLE"))
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]