github.com/dolthub/go-mysql-server@v0.18.0/enginetest/queries/null_range_tests.go (about)

     1  // Copyright 2022 Dolthub, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package queries
    16  
    17  import (
    18  	"github.com/dolthub/go-mysql-server/sql"
    19  )
    20  
    21  var NullRangeTests = []QueryTest{
    22  	{
    23  		Query: "select * from null_ranges where y IS NULL or y < 1",
    24  		Expected: []sql.Row{
    25  			{0, 0},
    26  			{3, nil},
    27  			{4, nil},
    28  		},
    29  	},
    30  	{
    31  		Query:    "select * from null_ranges where y IS NULL and y < 1",
    32  		Expected: []sql.Row{},
    33  	},
    34  	{
    35  		Query: "select * from null_ranges where y IS NULL or y IS NOT NULL",
    36  		Expected: []sql.Row{
    37  			{0, 0},
    38  			{1, 1},
    39  			{2, 2},
    40  			{3, nil},
    41  			{4, nil},
    42  		},
    43  	},
    44  	{
    45  		Query: "select * from null_ranges where y IS NOT NULL",
    46  		Expected: []sql.Row{
    47  			{0, 0},
    48  			{1, 1},
    49  			{2, 2},
    50  		},
    51  	},
    52  	{
    53  		Query: "select * from null_ranges where y IS NULL or y = 0 or y = 1",
    54  		Expected: []sql.Row{
    55  			{0, 0},
    56  			{1, 1},
    57  			{3, nil},
    58  			{4, nil},
    59  		},
    60  	},
    61  	{
    62  		Query: "select * from null_ranges where y IS NULL or y < 1 or y > 1",
    63  		Expected: []sql.Row{
    64  			{0, 0},
    65  			{2, 2},
    66  			{3, nil},
    67  			{4, nil},
    68  		},
    69  	},
    70  	{
    71  		Query: "select * from null_ranges where y IS NOT NULL and x > 1",
    72  		Expected: []sql.Row{
    73  			{2, 2},
    74  		},
    75  	}, {
    76  		Query: "select * from null_ranges where y IS NULL and x = 4",
    77  		Expected: []sql.Row{
    78  			{4, nil},
    79  		},
    80  	}, {
    81  		Query: "select * from null_ranges where y IS NULL and x > 1",
    82  		Expected: []sql.Row{
    83  			{3, nil},
    84  			{4, nil},
    85  		},
    86  	},
    87  	{
    88  		Query:    "select * from null_ranges where y IS NULL and y IS NOT NULL",
    89  		Expected: []sql.Row{},
    90  	},
    91  	{
    92  		Query:    "select * from null_ranges where y is NULL and y > -1 and y > -2",
    93  		Expected: []sql.Row{},
    94  	},
    95  	{
    96  		Query:    "select * from null_ranges where y > -1 and y < 7 and y IS NULL",
    97  		Expected: []sql.Row{},
    98  	},
    99  	{
   100  		Query: "select * from null_ranges where y > -1 and y > -2 and y IS NOT NULL",
   101  		Expected: []sql.Row{
   102  			{0, 0},
   103  			{1, 1},
   104  			{2, 2},
   105  		},
   106  	},
   107  	{
   108  		Query: "select * from null_ranges where y > -1 and y > 1 and y IS NOT NULL",
   109  		Expected: []sql.Row{
   110  			{2, 2},
   111  		},
   112  	},
   113  	{
   114  		Query: "select * from null_ranges where y < 6 and y > -1 and y IS NOT NULL",
   115  		Expected: []sql.Row{
   116  			{0, 0},
   117  			{1, 1},
   118  			{2, 2},
   119  		},
   120  	},
   121  }