This is an automated email from the ASF dual-hosted git repository. yiguolei 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 b35998a3b7 [Bug](datetimev2) Support cast datetimev2 to datetimev2 with different precision #16826 b35998a3b7 is described below commit b35998a3b706e470a35d49ba6f177505a5612d3b Author: Gabriel <gabrielleeb...@gmail.com> AuthorDate: Fri Feb 17 08:42:36 2023 +0800 [Bug](datetimev2) Support cast datetimev2 to datetimev2 with different precision #16826 --- .../java/org/apache/doris/analysis/CastExpr.java | 2 +- .../data/datatype_p0/datetimev2/test_exprs.out | 9 +++++ .../datatype_p0/datetimev2/test_exprs.groovy | 44 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java index 34f371471d..2261c69057 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java @@ -160,7 +160,7 @@ public class CastExpr extends Expr { return true; } // Disable no-op casting - return fromType.equals(toType) && !fromType.isDecimalV3(); + return fromType.equals(toType) && !fromType.isDecimalV3() && !fromType.isDatetimeV2(); } public static void initBuiltins(FunctionSet functionSet) { diff --git a/regression-test/data/datatype_p0/datetimev2/test_exprs.out b/regression-test/data/datatype_p0/datetimev2/test_exprs.out new file mode 100644 index 0000000000..18fdd0de4f --- /dev/null +++ b/regression-test/data/datatype_p0/datetimev2/test_exprs.out @@ -0,0 +1,9 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_all -- +2022-01-01T11:11:11.111 +2022-01-01T11:11:11.222 + +-- !sql_cast_datetimev2 -- +2022-01-01T11:11:11.111 +2022-01-01T11:11:11.222 + diff --git a/regression-test/suites/datatype_p0/datetimev2/test_exprs.groovy b/regression-test/suites/datatype_p0/datetimev2/test_exprs.groovy new file mode 100644 index 0000000000..89eba7c464 --- /dev/null +++ b/regression-test/suites/datatype_p0/datetimev2/test_exprs.groovy @@ -0,0 +1,44 @@ +// 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_exprs") { + + def table1 = "test_datetimev2_exprs" + + sql "drop table if exists ${table1}" + + sql """ + CREATE TABLE IF NOT EXISTS `${table1}` ( + `col` datetimev2(3) NULL COMMENT "" + ) ENGINE=OLAP + UNIQUE KEY(`col`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`col`) BUCKETS 8 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "in_memory" = "false", + "storage_format" = "V2" + ) + """ + + sql """insert into ${table1} values('2022-01-01 11:11:11.111'), + ('2022-01-01 11:11:11.222') + """ + qt_select_all "select * from ${table1} order by col" + + qt_sql_cast_datetimev2 " select cast(col as datetimev2(5)) col1 from ${table1} order by col1; " +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org