From b90ce6c081b03da1aad6aa5876e79f4c19dc8a39 Mon Sep 17 00:00:00 2001 From: ZhangYu0123 Date: Sun, 5 Mar 2023 10:33:15 +0800 Subject: [PATCH 1/2] fix --- fe/fe-core/src/main/cup/sql_parser.cup | 5 +- .../test_unsigned_int_compatibility.out | 18 ++++++ .../test_unsigned_int_compatibility.groovy | 55 +++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 regression-test/data/types_p0/unsigned/test_unsigned_int_compatibility.out create mode 100644 regression-test/suites/types_p0/unsigned/test_unsigned_int_compatibility.groovy diff --git a/fe/fe-core/src/main/cup/sql_parser.cup b/fe/fe-core/src/main/cup/sql_parser.cup index e252a8dd704f39..939729e55d538c 100644 --- a/fe/fe-core/src/main/cup/sql_parser.cup +++ b/fe/fe-core/src/main/cup/sql_parser.cup @@ -5744,6 +5744,9 @@ type ::= {: RESULT = Type.SMALLINT; :} | opt_signed_unsigned KW_INT opt_field_length {: RESULT = Type.INT; :} + // This is just for MySQL compatibility now. + | KW_UNSIGNED KW_INT opt_field_length + {: RESULT = Type.BIGINT; :} | KW_BIGINT opt_field_length {: RESULT = Type.BIGINT; :} | KW_LARGEINT opt_field_length @@ -5848,8 +5851,6 @@ opt_signed_unsigned ::= {: RESULT = true; :} | KW_SIGNED {: RESULT = true; :} - | KW_UNSIGNED - {: RESULT = false; :} ; type_def ::= diff --git a/regression-test/data/types_p0/unsigned/test_unsigned_int_compatibility.out b/regression-test/data/types_p0/unsigned/test_unsigned_int_compatibility.out new file mode 100644 index 00000000000000..0f8cd0f99b7bc4 --- /dev/null +++ b/regression-test/data/types_p0/unsigned/test_unsigned_int_compatibility.out @@ -0,0 +1,18 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !desc_tb -- +user_id LARGEINT No true \N +city VARCHAR(20) Yes true \N +value1 BIGINT Yes false \N REPLACE + +-- !select_tb -- +1 Beijing 21474836478 + +-- !desc_tb -- +user_id LARGEINT No true \N +city VARCHAR(20) Yes true \N +value1 BIGINT Yes false \N REPLACE +value2 BIGINT Yes false \N REPLACE + +-- !select_tb -- +1 Beijing 21474836478 \N +2 Beijing 21474836478 21474836478 diff --git a/regression-test/suites/types_p0/unsigned/test_unsigned_int_compatibility.groovy b/regression-test/suites/types_p0/unsigned/test_unsigned_int_compatibility.groovy new file mode 100644 index 00000000000000..5e704192697d01 --- /dev/null +++ b/regression-test/suites/types_p0/unsigned/test_unsigned_int_compatibility.groovy @@ -0,0 +1,55 @@ +// 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_unsigned_int_compatibility") { + def tableName = "test_unsigned_int_compatibility" + + sql """DROP TABLE IF EXISTS ${tableName}""" + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `user_id` LARGEINT NOT NULL COMMENT "用户id", + `city` VARCHAR(20) COMMENT "用户所在城市", + `value1` UNSIGNED INT COMMENT "value2" + ) + UNIQUE KEY(`user_id`, `city`) + DISTRIBUTED BY HASH(`user_id`) + PROPERTIES ( + "replication_num" = "1" , + "light_schema_change" = "true" + ); + """ + qt_desc_tb "DESC ${tableName}" + + sql """ + INSERT INTO ${tableName} VALUES + (1, 'Beijing', 21474836478); + """ + qt_select_tb "SELECT * FROM ${tableName}" + + sql """ + ALTER table ${tableName} ADD COLUMN value2 UNSIGNED INT; + """ + qt_desc_tb "DESC ${tableName}" + + sql """ + INSERT INTO ${tableName} VALUES + (2, 'Beijing', 21474836478, 21474836478); + """ + qt_select_tb "SELECT * FROM ${tableName}" + + sql "DROP TABLE ${tableName}" +} \ No newline at end of file From 276f26b35bdd54a2bb5476a8a3324bf28f5c6019 Mon Sep 17 00:00:00 2001 From: ZhangYu0123 Date: Sun, 5 Mar 2023 19:46:54 +0800 Subject: [PATCH 2/2] regression test --- .../types_p0/unsigned/test_unsigned_int_compatibility.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regression-test/suites/types_p0/unsigned/test_unsigned_int_compatibility.groovy b/regression-test/suites/types_p0/unsigned/test_unsigned_int_compatibility.groovy index 5e704192697d01..1a4681a20679de 100644 --- a/regression-test/suites/types_p0/unsigned/test_unsigned_int_compatibility.groovy +++ b/regression-test/suites/types_p0/unsigned/test_unsigned_int_compatibility.groovy @@ -49,7 +49,7 @@ suite("test_unsigned_int_compatibility") { INSERT INTO ${tableName} VALUES (2, 'Beijing', 21474836478, 21474836478); """ - qt_select_tb "SELECT * FROM ${tableName}" + qt_select_tb "SELECT * FROM ${tableName} order by user_id" sql "DROP TABLE ${tableName}" } \ No newline at end of file