diff --git a/scalar_udf_test.go b/scalar_udf_test.go index b9c2999f..0687352b 100644 --- a/scalar_udf_test.go +++ b/scalar_udf_test.go @@ -279,15 +279,15 @@ func TestANYScalarUDF(t *testing.T) { require.NoError(t, err) var count int - row := db.QueryRow(`SELECT my_null_count(10, 42, 2, 2, 2) AS msg`) + row := db.QueryRow(`SELECT my_null_count(10, 'hello', 2, [2], 2) AS msg`) require.NoError(t, row.Scan(&count)) require.Equal(t, 0, count) - row = db.QueryRow(`SELECT my_null_count(10, NULL, NULL) AS msg`) + row = db.QueryRow(`SELECT my_null_count(10, NULL, NULL, [NULL], {'hello': NULL}) AS msg`) require.NoError(t, row.Scan(&count)) require.Equal(t, 2, count) - row = db.QueryRow(`SELECT my_null_count(10) AS msg`) + row = db.QueryRow(`SELECT my_null_count(10, True) AS msg`) require.NoError(t, row.Scan(&count)) require.Equal(t, 0, count) diff --git a/vector_getters.go b/vector_getters.go index 29757ab0..c4e7b6b1 100644 --- a/vector_getters.go +++ b/vector_getters.go @@ -148,8 +148,12 @@ func (vec *vector) getList(rowIdx C.idx_t) []any { // Fill the slice with all child values. for i := C.idx_t(0); i < entry.length; i++ { - val := child.getFn(child, i+entry.offset) - slice = append(slice, val) + if child.isSQLNull { + slice = append(slice, nil) + } else { + val := child.getFn(child, i+entry.offset) + slice = append(slice, val) + } } return slice } @@ -158,8 +162,12 @@ func (vec *vector) getStruct(rowIdx C.idx_t) map[string]any { m := map[string]any{} for i := 0; i < len(vec.childVectors); i++ { child := &vec.childVectors[i] - val := child.getFn(child, rowIdx) - m[vec.structEntries[i].Name()] = val + if child.isSQLNull { + m[vec.structEntries[i].Name()] = nil + } else { + val := child.getFn(child, rowIdx) + m[vec.structEntries[i].Name()] = val + } } return m }