From 87fe41351f9871f4fa855e26f1aca053cb8cab8d Mon Sep 17 00:00:00 2001 From: xudong963 Date: Wed, 12 Feb 2025 17:27:14 +0800 Subject: [PATCH 1/2] Add test for nullable doesn't work when create memory table --- .../sqllogictest/test_files/create_table.slt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 datafusion/sqllogictest/test_files/create_table.slt diff --git a/datafusion/sqllogictest/test_files/create_table.slt b/datafusion/sqllogictest/test_files/create_table.slt new file mode 100644 index 0000000000000..109944e0e1ce3 --- /dev/null +++ b/datafusion/sqllogictest/test_files/create_table.slt @@ -0,0 +1,46 @@ +# 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. + +# Test memory table fields with correct nullable +statement ok +CREATE or replace TABLE table_with_pk ( + sn INT PRIMARY KEY NOT NULL, + ts TIMESTAMP WITH TIME ZONE NOT NULL, + currency VARCHAR(3) NOT NULL, + amount FLOAT + ) as VALUES + (0, '2022-01-01 06:00:00Z'::timestamp, 'EUR', 30.0), + (1, '2022-01-01 08:00:00Z'::timestamp, 'EUR', 50.0), + (2, '2022-01-01 11:30:00Z'::timestamp, 'TRY', 75.0), + (3, '2022-01-02 12:00:00Z'::timestamp, 'EUR', 200.0); + +statement ok +set datafusion.catalog.information_schema = true; + +query TTTTTT +show columns FROM table_with_pk; +---- +datafusion public table_with_pk sn Int32 NO +datafusion public table_with_pk ts Timestamp(Nanosecond, Some("+00:00")) NO +datafusion public table_with_pk currency Utf8 NO +datafusion public table_with_pk amount Float32 YES + +statement ok +drop table table_with_pk; + +statement ok +set datafusion.catalog.information_schema = false; From 372ba9504e1dd4e4b47719141f5986cfaf7c1235 Mon Sep 17 00:00:00 2001 From: xudong963 Date: Thu, 13 Feb 2025 10:27:42 +0800 Subject: [PATCH 2/2] change location --- .../sqllogictest/test_files/create_table.slt | 46 ------------------- datafusion/sqllogictest/test_files/ddl.slt | 28 +++++++++++ 2 files changed, 28 insertions(+), 46 deletions(-) delete mode 100644 datafusion/sqllogictest/test_files/create_table.slt diff --git a/datafusion/sqllogictest/test_files/create_table.slt b/datafusion/sqllogictest/test_files/create_table.slt deleted file mode 100644 index 109944e0e1ce3..0000000000000 --- a/datafusion/sqllogictest/test_files/create_table.slt +++ /dev/null @@ -1,46 +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. - -# Test memory table fields with correct nullable -statement ok -CREATE or replace TABLE table_with_pk ( - sn INT PRIMARY KEY NOT NULL, - ts TIMESTAMP WITH TIME ZONE NOT NULL, - currency VARCHAR(3) NOT NULL, - amount FLOAT - ) as VALUES - (0, '2022-01-01 06:00:00Z'::timestamp, 'EUR', 30.0), - (1, '2022-01-01 08:00:00Z'::timestamp, 'EUR', 50.0), - (2, '2022-01-01 11:30:00Z'::timestamp, 'TRY', 75.0), - (3, '2022-01-02 12:00:00Z'::timestamp, 'EUR', 200.0); - -statement ok -set datafusion.catalog.information_schema = true; - -query TTTTTT -show columns FROM table_with_pk; ----- -datafusion public table_with_pk sn Int32 NO -datafusion public table_with_pk ts Timestamp(Nanosecond, Some("+00:00")) NO -datafusion public table_with_pk currency Utf8 NO -datafusion public table_with_pk amount Float32 YES - -statement ok -drop table table_with_pk; - -statement ok -set datafusion.catalog.information_schema = false; diff --git a/datafusion/sqllogictest/test_files/ddl.slt b/datafusion/sqllogictest/test_files/ddl.slt index 5e229075273dd..196e2f30518e8 100644 --- a/datafusion/sqllogictest/test_files/ddl.slt +++ b/datafusion/sqllogictest/test_files/ddl.slt @@ -840,3 +840,31 @@ DROP TABLE t1; statement ok DROP TABLE t2; + +# Test memory table fields with correct nullable +statement ok +CREATE or replace TABLE table_with_pk ( + sn INT PRIMARY KEY NOT NULL, + ts TIMESTAMP WITH TIME ZONE NOT NULL, + currency VARCHAR(3) NOT NULL, + amount FLOAT + ) as VALUES + (0, '2022-01-01 06:00:00Z'::timestamp, 'EUR', 30.0), + (1, '2022-01-01 08:00:00Z'::timestamp, 'EUR', 50.0), + (2, '2022-01-01 11:30:00Z'::timestamp, 'TRY', 75.0), + (3, '2022-01-02 12:00:00Z'::timestamp, 'EUR', 200.0); + +query TTTTTT +show columns FROM table_with_pk; +---- +datafusion public table_with_pk sn Int32 NO +datafusion public table_with_pk ts Timestamp(Nanosecond, Some("+00:00")) NO +datafusion public table_with_pk currency Utf8 NO +datafusion public table_with_pk amount Float32 YES + +statement ok +drop table table_with_pk; + +statement ok +set datafusion.catalog.information_schema = false; +