From e569a6b3fcd4b20521526d7c88e6a182373eefbd Mon Sep 17 00:00:00 2001 From: zhangstar333 <2561612514@qq.com> Date: Tue, 31 Oct 2023 22:16:36 +0800 Subject: [PATCH] add test case --- .../data/correctness_p0/test_and_or.out | 77 +++++++++++++++++++ .../suites/correctness_p0/test_and_or.groovy | 74 ++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 regression-test/data/correctness_p0/test_and_or.out create mode 100644 regression-test/suites/correctness_p0/test_and_or.groovy diff --git a/regression-test/data/correctness_p0/test_and_or.out b/regression-test/data/correctness_p0/test_and_or.out new file mode 100644 index 00000000000000..96cb7c10a94738 --- /dev/null +++ b/regression-test/data/correctness_p0/test_and_or.out @@ -0,0 +1,77 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select3 -- +1 \N true false true false true true +2 \N true false true false false false + +-- !select1 -- +false +false + +-- !select2 -- +false +false + +-- !select3 -- +true +true + +-- !select4 -- +true +true + +-- !select5 -- +false +true + +-- !select6 -- +false +true + +-- !select7 -- +false +false + +-- !select8 -- +\N +\N + +-- !select9 -- +false +true + +-- !select10 -- +false +false + +-- !select11 -- +\N +\N + +-- !select12 -- +\N +\N + +-- !select13 -- +\N +\N + +-- !select14 -- +\N +\N + +-- !select15 -- +false +true + +-- !select16 -- +false +true + +-- !select17 -- +false +true + +-- !select18 -- +false +false + diff --git a/regression-test/suites/correctness_p0/test_and_or.groovy b/regression-test/suites/correctness_p0/test_and_or.groovy new file mode 100644 index 00000000000000..5e3569e26dad5a --- /dev/null +++ b/regression-test/suites/correctness_p0/test_and_or.groovy @@ -0,0 +1,74 @@ +// 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. + +// The cases is copied from https://github.com/trinodb/trino/tree/master +// /testing/trino-product-tests/src/main/resources/sql-tests/testcases/aggregate +// and modified by Doris. + +suite("test_and_or") { + def tableName = "test_and_or" + + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ + CREATE TABLE `test_and_or` ( + `id` int(11) NULL, + `k_null` boolean NULL, + `k_true` boolean NULL, + `k_false` boolean NULL, + `k_true_not` boolean not NULL, + `k_false_not` boolean not NULL, + `k_true_false` boolean not NULL, + `k_true_false_not` boolean not NULL + ) ENGINE=OLAP + DUPLICATE KEY(`id`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`id`) BUCKETS 10 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "min_load_replica_num" = "-1", + "is_being_synced" = "false", + "storage_format" = "V2", + "light_schema_change" = "true", + "disable_auto_compaction" = "false", + "enable_single_replica_compaction" = "false" + ); + """ + + sql """ insert into test_and_or values(1,NULL,true,false,true,false,true,true)""" + sql "insert into test_and_or values(2,NULL,true,false,true,false,false,false);" + + + qt_select3 """select * from test_and_or order by 1,2,3;""" + qt_select1 """ select (k_false_not and k_false_not) and (k_null or k_true) from test_and_or order by 1;""" + qt_select2 """ select (k_null and k_false) and (k_null or k_true) from test_and_or order by 1;""" + qt_select3 """ select (k_null or k_true) and (k_false_not or k_true_not) from test_and_or order by 1;""" + qt_select4 """ select (k_true_not or k_false_not) and (k_null or k_true) from test_and_or order by 1;""" + qt_select5 """ select (k_true_false_not or k_true_false) and (k_true_not or k_false_not) from test_and_or order by 1;""" + qt_select6 """ select (k_true_not or k_true_false) and (k_true_false_not or k_false_not) from test_and_or order by 1;""" + qt_select7 """ select (k_true_not and k_false_not) and (k_true_false_not or k_true) from test_and_or order by 1;""" + qt_select8 """ select (k_null or k_false) and (k_false_not or k_true_not) from test_and_or order by 1; """ + qt_select9 """ select (k_false and k_true_not) or (k_true and k_true_false_not) from test_and_or order by 1;""" + qt_select10 """ select (k_false_not and k_true_not) or (k_null and k_false) from test_and_or order by 1;""" + qt_select11 """ select (k_false_not and k_false_not) or (k_null and k_true) from test_and_or order by 1;""" + qt_select12 """ select (k_null and k_false) or (k_null and k_true) from test_and_or order by 1;""" + qt_select13 """ select (k_null and k_true) or (k_false_not and k_true_not) from test_and_or order by 1;""" + qt_select14 """ select (k_true_not and k_false_not) or (k_null and k_true) from test_and_or order by 1;""" + qt_select15 """ select (k_true_false_not and k_true_false) or (k_true_not and k_false_not) from test_and_or order by 1;""" + qt_select16 """ select (k_true_not and k_true_false) or(k_true_false_not and k_false_not) from test_and_or order by 1;""" + qt_select17 """ select (k_true_not and k_false_not) or (k_true_false_not and k_true) from test_and_or order by 1;""" + qt_select18 """ select (k_null and k_false) or (k_false_not and k_true_not) from test_and_or order by 1; """ +}