Skip to content

Commit c22a9f7

Browse files
authored
Merge pull request #3004 from dolthub/fulghum/tuple_is_null
Add support for `IS NULL` expressions with records
2 parents b79502c + 6f1d56c commit c22a9f7

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

sql/expression/isnull.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ func (e *IsNull) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
5454
return nil, err
5555
}
5656

57+
// Slices of typed values (e.g. Record and Composite types in Postgres) evaluate
58+
// to NULL if all of their entries are NULL.
59+
if tupleValue, ok := v.([]types.TupleValue); ok {
60+
for _, typedValue := range tupleValue {
61+
if typedValue.Value != nil {
62+
return false, nil
63+
}
64+
}
65+
return true, nil
66+
}
67+
5768
return v == nil, nil
5869
}
5970

sql/types/tuple_value.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2025 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 types
16+
17+
import "github.com/dolthub/go-mysql-server/sql"
18+
19+
// TupleValue represents a value and its associated type information. TupleValue is used by collections of
20+
// values where the type information is not consistent across all values (e.g. Records in Postgres).
21+
type TupleValue struct {
22+
Value any
23+
Type sql.Type
24+
}

0 commit comments

Comments
 (0)