This is an automated email from the ASF dual-hosted git repository.
morrysnow 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 a90286a1229 [fix](mv) change nvl to ifnull when create mv (#34272)
(#37541)
a90286a1229 is described below
commit a90286a12298274f2db73efda1323ee7286f969a
Author: starocean999 <[email protected]>
AuthorDate: Tue Jul 9 18:57:32 2024 +0800
[fix](mv) change nvl to ifnull when create mv (#34272) (#37541)
pick from master #34272
---
.../org/apache/doris/rewrite/FunctionAlias.java | 2 +-
regression-test/data/mv_p0/test_nvl/test_nvl.out | 17 +++++
.../suites/mv_p0/test_nvl/test_nvl.groovy | 75 ++++++++++++++++++++++
3 files changed, 93 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FunctionAlias.java
b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FunctionAlias.java
index a5388bdceaa..9976a291450 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FunctionAlias.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FunctionAlias.java
@@ -39,7 +39,7 @@ public final class FunctionAlias implements ExprRewriteRule {
.put("schema", "database").put("day",
"dayofmonth").put("date_add", "days_add").put("adddate", "days_add")
.put("date_sub", "days_sub").put("subdate",
"days_sub").put("lcase", "lower")
.put("add_months", "months_add")
- .put("current_timestamp", "now").put("localtime",
"now").put("localtimestamp", "now").put("ifnull", "nvl")
+ .put("current_timestamp", "now").put("localtime",
"now").put("localtimestamp", "now").put("nvl", "ifnull")
.put("rand", "random").put("sha", "sha1").put("substr",
"substring").put("ucase", "upper").build();
@Override
diff --git a/regression-test/data/mv_p0/test_nvl/test_nvl.out
b/regression-test/data/mv_p0/test_nvl/test_nvl.out
new file mode 100644
index 00000000000..77b859604c7
--- /dev/null
+++ b/regression-test/data/mv_p0/test_nvl/test_nvl.out
@@ -0,0 +1,17 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !select_mv --
+1
+2
+
+-- !select_mv --
+1
+2
+
+-- !select_mv --
+1
+2
+
+-- !select_mv --
+1
+2
+
diff --git a/regression-test/suites/mv_p0/test_nvl/test_nvl.groovy
b/regression-test/suites/mv_p0/test_nvl/test_nvl.groovy
new file mode 100644
index 00000000000..e7c0d32f826
--- /dev/null
+++ b/regression-test/suites/mv_p0/test_nvl/test_nvl.groovy
@@ -0,0 +1,75 @@
+// 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 ("test_nvl") {
+ sql """ drop table if exists dwd;"""
+
+ sql """
+ CREATE TABLE `dwd` (
+ `id` bigint(20) NULL COMMENT 'id',
+ `created_at` datetime NULL,
+ `dt` date NULL
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`id`)
+ DISTRIBUTED BY HASH(`id`) BUCKETS 10
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ );
+ """
+
+ sql """insert into dwd(id) values(1);"""
+
+ createMV ("""
+ create materialized view dwd_mv as select nvl(id,0) from dwd;
+ """)
+
+ sql """insert into dwd(id) values(2);"""
+
+ explain {
+ sql("select nvl(id,0) from dwd order by 1;")
+ contains "(dwd_mv)"
+ }
+ qt_select_mv "select nvl(id,0) from dwd order by 1;"
+
+ explain {
+ sql("select ifnull(id,0) from dwd order by 1;")
+ contains "(dwd_mv)"
+ }
+ qt_select_mv "select ifnull(id,0) from dwd order by 1;"
+
+ sql """ drop materialized view dwd_mv on dwd;
+ """
+
+ createMV ("""
+ create materialized view dwd_mv as select ifnull(id,0) from dwd;
+ """)
+
+ explain {
+ sql("select nvl(id,0) from dwd order by 1;")
+ contains "(dwd_mv)"
+ }
+ qt_select_mv "select nvl(id,0) from dwd order by 1;"
+
+ explain {
+ sql("select ifnull(id,0) from dwd order by 1;")
+ contains "(dwd_mv)"
+ }
+ qt_select_mv "select ifnull(id,0) from dwd order by 1;"
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]