This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 0287bc01c47 branch-2.1: [fix](ddl) Wrong result of scalar type `toString` for DATETIMEV2 #50237 (#50905) 0287bc01c47 is described below commit 0287bc01c475e9bf08f99b5ade079fa6823a3d85 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Wed May 21 14:22:14 2025 +0800 branch-2.1: [fix](ddl) Wrong result of scalar type `toString` for DATETIMEV2 #50237 (#50905) Cherry-picked from #50237 Co-authored-by: Uniqueyou <wangyix...@selectdb.com> --- .../apache/doris/common/util/PropertyAnalyzer.java | 8 +- .../test_sequence_col_datetimev2.groovy | 98 ++++++++++++++++++++++ 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java index 62bd204edcd..81ab5f8d206 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java @@ -36,6 +36,7 @@ import org.apache.doris.common.DdlException; import org.apache.doris.datasource.CatalogIf; import org.apache.doris.datasource.CatalogMgr; import org.apache.doris.datasource.ExternalCatalog; +import org.apache.doris.nereids.types.DataType; import org.apache.doris.policy.Policy; import org.apache.doris.policy.StoragePolicy; import org.apache.doris.resource.Tag; @@ -1047,11 +1048,14 @@ public class PropertyAnalyzer { if (typeStr != null && keysType != KeysType.UNIQUE_KEYS) { throw new AnalysisException("sequence column only support UNIQUE_KEYS"); } - PrimitiveType type = PrimitiveType.valueOf(typeStr.toUpperCase()); + + Type type = DataType.convertFromString(typeStr.toLowerCase()).toCatalogDataType(); + if (!type.isFixedPointType() && !type.isDateType()) { throw new AnalysisException("sequence type only support integer types and date types"); } - return ScalarType.createType(type); + + return type; } public static String analyzeSequenceMapCol(Map<String, String> properties, KeysType keysType) diff --git a/regression-test/suites/correctness_p0/test_sequence_col_datetimev2.groovy b/regression-test/suites/correctness_p0/test_sequence_col_datetimev2.groovy new file mode 100644 index 00000000000..5bc1247be02 --- /dev/null +++ b/regression-test/suites/correctness_p0/test_sequence_col_datetimev2.groovy @@ -0,0 +1,98 @@ +// 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_sequence_col_datetimev2") { + + def tableName0 = "test_sequence_col_datetimev2" + + sql """ DROP TABLE IF EXISTS ${tableName0} """ + + sql """ + CREATE TABLE ${tableName0} + ( + project_id BIGINT NOT NULL , + consume_date DATETIMEV2 NOT NULL, + order_id BIGINT NOT NULL , + combo_extend JSONB DEFAULT NULL, + age INT, + name varchar(20), + write_time DATETIME DEFAULT CURRENT_TIMESTAMP + ) UNIQUE KEY(project_id, consume_date,order_id) + DISTRIBUTED BY HASH(project_id) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "enable_unique_key_merge_on_write" = "true", + "function_column.sequence_type" = "datetimev2" + ); + """ + + def res = sql " show create table ${tableName0} " + + logger.info("show create table ${tableName0} : " + res[0][1]) + + assertTrue(res[0][1].contains("\"function_column.sequence_type\" = \"datetimev2(0)\"")) + + sql """ DROP TABLE IF EXISTS ${tableName0} """ + + sql (res[0][1]) + + def show_res = sql " show create table ${tableName0} " + + logger.info("show create table ${tableName0} : " + show_res[0][1]) + + assertTrue(res[0][1].contains("\"function_column.sequence_type\" = \"datetimev2(0)\"")) + + def tableName1 = "test_sequence_col_datetimev2_1" + + sql """ DROP TABLE IF EXISTS ${tableName1} """ + + sql """ + CREATE TABLE ${tableName1} + ( + project_id BIGINT NOT NULL , + consume_date DATETIMEV2 NOT NULL, + order_id BIGINT NOT NULL , + combo_extend JSONB DEFAULT NULL, + age INT, + name varchar(20), + write_time DATETIME DEFAULT CURRENT_TIMESTAMP + ) UNIQUE KEY(project_id, consume_date,order_id) + DISTRIBUTED BY HASH(project_id) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "enable_unique_key_merge_on_write" = "true", + "function_column.sequence_type" = "datetimev2(3)" + ); + """ + + res = sql " show create table ${tableName1} " + + logger.info("show create table ${tableName1} : " + res[0][1]) + + assertTrue(res[0][1].contains("\"function_column.sequence_type\" = \"datetimev2(3)\"")) + + sql """ DROP TABLE IF EXISTS ${tableName1} """ + + sql (res[0][1]) + + show_res = sql " show create table ${tableName1} " + + logger.info("show create table ${tableName1} : " + show_res[0][1]) + + assertTrue(res[0][1].contains("\"function_column.sequence_type\" = \"datetimev2(3)\"")) +} + --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org