This is an automated email from the ASF dual-hosted git repository. dataroaring 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 4c7c5608129 Revert "[fix](column) Math default value showed incorrectly" (#48178) 4c7c5608129 is described below commit 4c7c5608129bb346b33996882417881505518e46 Author: Uniqueyou <wangyix...@selectdb.com> AuthorDate: Fri Feb 21 19:26:02 2025 +0800 Revert "[fix](column) Math default value showed incorrectly" (#48178) set double default failed ``` mysql> CREATE TABLE t ( -> id int, -> age double default 1.1 -> ) -> DISTRIBUTED BY HASH(`id`) BUCKETS 5 -> PROPERTIES ( -> "replication_num" = "1" -> ); Query OK, 0 rows affected (0.01 sec) mysql> show create table t\G *************************** 1. row *************************** Table: t Create Table: CREATE TABLE `t` ( `id` int NULL, `age` double NULL ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 5 PROPERTIES ( "replication_allocation" = "tag.location.default: 1" ); 1 row in set (0.01 sec) ``` **No need to merge into 3.0/2.1** --- .../main/java/org/apache/doris/catalog/Column.java | 5 +- .../plans/commands/ShowCreateTableCommandTest.java | 60 --------------------- .../data/correctness_p0/test_default_double.out | Bin 0 -> 296 bytes .../correctness_p0/test_default_double.groovy | 48 +++++++++++++++++ 4 files changed, 50 insertions(+), 63 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java index b2678558dff..f7d4065b00c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java @@ -997,15 +997,14 @@ public class Column implements GsonPostProcessable { if (isAutoInc) { sb.append(" AUTO_INCREMENT(").append(autoIncInitValue).append(")"); } - if (defaultValue != null && getDataType() != PrimitiveType.HLL && getDataType() != PrimitiveType.BITMAP - && getDataType() != PrimitiveType.DOUBLE) { + if (defaultValue != null && getDataType() != PrimitiveType.HLL && getDataType() != PrimitiveType.BITMAP) { if (defaultValueExprDef != null) { sb.append(" DEFAULT ").append(defaultValue).append(""); } else { sb.append(" DEFAULT \"").append(defaultValue).append("\""); } } - if ((getDataType() == PrimitiveType.BITMAP || getDataType() == PrimitiveType.DOUBLE) && defaultValue != null) { + if ((getDataType() == PrimitiveType.BITMAP) && defaultValue != null) { if (defaultValueExprDef != null) { sb.append(" DEFAULT ").append(defaultValueExprDef.getExprName()).append(""); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowCreateTableCommandTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowCreateTableCommandTest.java deleted file mode 100644 index c966cc24361..00000000000 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowCreateTableCommandTest.java +++ /dev/null @@ -1,60 +0,0 @@ -// 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. - -package org.apache.doris.nereids.trees.plans.commands; - -import org.apache.doris.nereids.parser.NereidsParser; -import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo; -import org.apache.doris.nereids.trees.plans.logical.LogicalPlan; -import org.apache.doris.qe.ShowResultSet; -import org.apache.doris.utframe.TestWithFeService; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.util.List; -import java.util.stream.Collectors; - -public class ShowCreateTableCommandTest extends TestWithFeService { - @Override - protected void runBeforeAll() throws Exception { - createDatabase("test"); - connectContext.setDatabase("test"); - } - - @Override - public void createTable(String sql) throws Exception { - LogicalPlan plan = new NereidsParser().parseSingle(sql); - Assertions.assertTrue(plan instanceof CreateTableCommand); - ((CreateTableCommand) plan).run(connectContext, null); - } - - @Test - public void testCreateTableDefaultValueMath() throws Exception { - // test - String sql = "create table if not exists test.tbl\n" + "(k1 int, k2 double default E, k3 double default PI)\n" - + "distributed by hash(k1) buckets 1\n" - + "properties('replication_num' = '1'); "; - createTable(sql); - ShowCreateTableCommand showCreateTableCommand = new ShowCreateTableCommand(new TableNameInfo("test", "tbl"), - false); - ShowResultSet result = showCreateTableCommand.doRun(connectContext, null); - String resultStr = result.getResultRows().stream().flatMap(List::stream).collect(Collectors.joining(" ")); - Assertions.assertTrue(resultStr.contains("`k2` double NULL DEFAULT E")); - Assertions.assertTrue(resultStr.contains("`k3` double NULL DEFAULT PI")); - } -} diff --git a/regression-test/data/correctness_p0/test_default_double.out b/regression-test/data/correctness_p0/test_default_double.out new file mode 100644 index 00000000000..c047df89cd4 Binary files /dev/null and b/regression-test/data/correctness_p0/test_default_double.out differ diff --git a/regression-test/suites/correctness_p0/test_default_double.groovy b/regression-test/suites/correctness_p0/test_default_double.groovy new file mode 100644 index 00000000000..76226bc1356 --- /dev/null +++ b/regression-test/suites/correctness_p0/test_default_double.groovy @@ -0,0 +1,48 @@ +// 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_default_double") { + def tableName = "test_default_double" + + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} + ( + k TINYINT, + v1 DOUBLE NOT NULL DEFAULT PI, + v2 DOUBLE NOT NULL DEFAULT E, + v3 DOUBLE NOT NULL DEFAULT 1.2345, + ) + UNIQUE KEY(K) + DISTRIBUTED BY HASH(k) + PROPERTIES("replication_num" = "1"); + """ + + def res = sql "SHOW CREATE TABLE ${tableName}" + + // test show create table + assertTrue(res[0][1].contains("`v1` double NOT NULL DEFAULT 3.141592653589793")) + assertTrue(res[0][1].contains("`v2` double NOT NULL DEFAULT 2.718281828459045")) + assertTrue(res[0][1].contains("`v3` double NOT NULL DEFAULT \"1.2345\"")) + + // test insert into. + sql " insert into ${tableName} (k) values (1); " + sql " insert into ${tableName} (k) values (2); " + sql " insert into ${tableName} (k) values (3); " + sql " insert into ${tableName} (k) values (4); " + qt_insert_into1 """ select * from ${tableName} order by k; """ +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org