This is an automated email from the ASF dual-hosted git repository.
panxiaolei 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 62440f3140 [Bug](Materialized-View) forbiden mv rewrite on create view
and remove duplicate method getIsM… (#17194)
62440f3140 is described below
commit 62440f314073ba15b69dc0f59caebf4c3efbb64e
Author: Pxl <[email protected]>
AuthorDate: Wed Mar 1 13:46:56 2023 +0800
[Bug](Materialized-View) forbiden mv rewrite on create view and remove
duplicate method getIsM… (#17194)
1. forbiden mv rewrite on create view to avoid select fail
2. remove duplicate method getIsMaterialized
---
.../org/apache/doris/analysis/CreateViewStmt.java | 1 +
.../org/apache/doris/analysis/DescriptorTable.java | 2 +-
.../org/apache/doris/analysis/TupleDescriptor.java | 4 --
.../doris/analysis/TupleIsNullPredicate.java | 2 +-
.../org/apache/doris/planner/AnalyticPlanner.java | 2 +-
.../mv_with_view/mv_with_view.out | 12 ++++
.../mv_with_view/mv_with_view.groovy | 65 ++++++++++++++++++++++
7 files changed, 81 insertions(+), 7 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateViewStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateViewStmt.java
index 7242f3bcaa..936f621fee 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateViewStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateViewStmt.java
@@ -78,6 +78,7 @@ public class CreateViewStmt extends BaseViewStmt {
// Analyze view define statement
Analyzer viewAnalyzer = new Analyzer(analyzer);
+ viewDefStmt.forbiddenMVRewrite();
viewDefStmt.analyze(viewAnalyzer);
createColumnAndViewDefs(analyzer);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java
index 72c4803439..2f8303915c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java
@@ -189,7 +189,7 @@ public class DescriptorTable {
for (TupleDescriptor tupleD : tupleDescs.values()) {
// inline view of a non-constant select has a non-materialized
tuple descriptor
// in the descriptor table just for type checking, which we need
to skip
- if (tupleD.getIsMaterialized()) {
+ if (tupleD.isMaterialized()) {
result.addToTupleDescriptors(tupleD.toThrift());
// an inline view of a constant select has a materialized tuple
// but its table has no id
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleDescriptor.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleDescriptor.java
index 01b099a2ca..b12e1684e6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleDescriptor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleDescriptor.java
@@ -169,10 +169,6 @@ public class TupleDescriptor {
return byteSize;
}
- public boolean getIsMaterialized() {
- return isMaterialized;
- }
-
public void setIsMaterialized(boolean value) {
isMaterialized = value;
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleIsNullPredicate.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleIsNullPredicate.java
index 2f5de7d4fc..98e51eca03 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleIsNullPredicate.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleIsNullPredicate.java
@@ -134,7 +134,7 @@ public class TupleIsNullPredicate extends Predicate {
// Assert that all tids are materialized.
for (TupleId tid : tids) {
TupleDescriptor tupleDesc = analyzer.getTupleDesc(tid);
- Preconditions.checkState(tupleDesc.getIsMaterialized());
+ Preconditions.checkState(tupleDesc.isMaterialized());
}
// Perform the wrapping.
List<Expr> result = Lists.newArrayListWithCapacity(inputExprs.size());
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/AnalyticPlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/AnalyticPlanner.java
index 46a21c6ed4..bfe9177f63 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/AnalyticPlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/AnalyticPlanner.java
@@ -787,7 +787,7 @@ public class AnalyticPlanner {
for (WindowGroup g : windowGroups) {
TupleDescriptor outputTuple = g.physicalOutputTuple;
- Preconditions.checkState(outputTuple.getIsMaterialized());
+ Preconditions.checkState(outputTuple.isMaterialized());
Preconditions.checkState(outputTuple.getByteSize() != -1);
totalOutputTupleSize += outputTuple.getByteSize();
}
diff --git
a/regression-test/data/materialized_view_p0/mv_with_view/mv_with_view.out
b/regression-test/data/materialized_view_p0/mv_with_view/mv_with_view.out
new file mode 100644
index 0000000000..e73b852bfa
--- /dev/null
+++ b/regression-test/data/materialized_view_p0/mv_with_view/mv_with_view.out
@@ -0,0 +1,12 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !select_star --
+1 1 1 a
+2 2 2 b
+3 -3 \N c
+
+-- !select_mv --
+1 1 1
+
+-- !select_mv --
+1 1 a
+
diff --git
a/regression-test/suites/materialized_view_p0/mv_with_view/mv_with_view.groovy
b/regression-test/suites/materialized_view_p0/mv_with_view/mv_with_view.groovy
new file mode 100644
index 0000000000..4b794b7cb1
--- /dev/null
+++
b/regression-test/suites/materialized_view_p0/mv_with_view/mv_with_view.groovy
@@ -0,0 +1,65 @@
+// 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.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite ("mv_with_view") {
+ sql """ DROP TABLE IF EXISTS d_table; """
+
+ sql """
+ create table d_table (
+ k1 int null,
+ k2 int not null,
+ k3 bigint null,
+ k4 varchar(100) null
+ )
+ duplicate key (k1,k2,k3)
+ distributed BY hash(k1) buckets 3
+ properties("replication_num" = "1");
+ """
+
+ sql """insert into d_table select 1,1,1,'a';"""
+ sql """insert into d_table select 2,2,2,'b';"""
+
+ createMV("create materialized view k132 as select k1,k3,k2 from d_table;")
+
+ sql """insert into d_table select 3,-3,null,'c';"""
+
+ explain {
+ sql("select * from d_table order by k1;")
+ contains "(d_table)"
+ }
+ qt_select_star "select * from d_table order by k1;"
+
+ sql """
+ create view v_k132 as select k1,k3,k2 from d_table where k1 = 1;
+ """
+ explain {
+ sql("select * from v_k132 order by k1;")
+ contains "(k132)"
+ }
+ qt_select_mv "select * from v_k132 order by k1;"
+
+ sql """
+ create view v_k124 as select k1,k2,k4 from d_table where k1 = 1;
+ """
+ explain {
+ sql("select * from v_k124 order by k1;")
+ contains "(d_table)"
+ }
+ qt_select_mv "select * from v_k124 order by k1;"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]