This is an automated email from the ASF dual-hosted git repository.
panxiaolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 608b5a6c59 [Bug](materialized-view) fix change base schema when create
mv (#23607) (#23814)
608b5a6c59 is described below
commit 608b5a6c5939e4255e33c48b76879932571867e7
Author: Pxl <[email protected]>
AuthorDate: Mon Sep 4 10:20:10 2023 +0800
[Bug](materialized-view) fix change base schema when create mv (#23607)
(#23814)
fix change base schema when create mv
---
.../org/apache/doris/analysis/MVColumnItem.java | 1 +
.../doris/alter/MaterializedViewHandlerTest.java | 2 +-
.../data/mv_p0/varchar_length/varchar_length.out | 8 +++++
.../mv_p0/varchar_length/varchar_length.groovy | 41 ++++++++++++++++++++++
4 files changed, 51 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnItem.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnItem.java
index 01e0b01b40..d61a3ea862 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnItem.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnItem.java
@@ -92,6 +92,7 @@ public class MVColumnItem {
this.type = defineExpr.getType();
if (this.type instanceof ScalarType && this.type.isStringType()) {
+ this.type = new ScalarType(type.getPrimitiveType());
((ScalarType) this.type).setMaxLength();
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
b/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
index 84bf21e8e5..4c1dd4fd93 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
@@ -240,7 +240,7 @@ public class MaterializedViewHandlerTest {
Assert.assertTrue(newMVColumn.isKey());
Assert.assertEquals(null, newMVColumn.getAggregationType());
Assert.assertEquals(false,
newMVColumn.isAggregationTypeImplicit());
- Assert.assertEquals(Type.VARCHAR, newMVColumn.getType());
+ Assert.assertEquals(Type.VARCHAR.getPrimitiveType(),
newMVColumn.getType().getPrimitiveType());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
diff --git a/regression-test/data/mv_p0/varchar_length/varchar_length.out
b/regression-test/data/mv_p0/varchar_length/varchar_length.out
new file mode 100644
index 0000000000..d944f69b4a
--- /dev/null
+++ b/regression-test/data/mv_p0/varchar_length/varchar_length.out
@@ -0,0 +1,8 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !select_exp --
+test1 UNIQUE_KEYS vid VARCHAR(1) VARCHAR(1) No true
\N true
+ report_time INT INT No true \N
true
+
+mv_test UNIQUE_KEYS mv_report_time INT INT No true
\N true `report_time`
+ mv_vid VARCHAR(65533) VARCHAR(65533) No true \N
REPLACE true `vid`
+
diff --git a/regression-test/suites/mv_p0/varchar_length/varchar_length.groovy
b/regression-test/suites/mv_p0/varchar_length/varchar_length.groovy
new file mode 100644
index 0000000000..476758dec8
--- /dev/null
+++ b/regression-test/suites/mv_p0/varchar_length/varchar_length.groovy
@@ -0,0 +1,41 @@
+// 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 ("varchar_length") {
+
+ sql """DROP TABLE IF EXISTS test1; """
+
+ sql """
+ CREATE TABLE test1(
+ vid VARCHAR(1) NOT NULL COMMENT "",
+ report_time int NOT NULL COMMENT ''
+ )
+ ENGINE=OLAP
+ UNIQUE KEY(vid, report_time)
+ DISTRIBUTED BY HASH(vid) BUCKETS AUTO
+ PROPERTIES
+ (
+ "replication_num" = "1"
+ );
+ """
+
+ createMV ("CREATE MATERIALIZED VIEW mv_test as SELECT report_time, vid
FROM test1 ORDER BY report_time DESC; ")
+
+ qt_select_exp "desc test1 all"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]