Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions runtime/ztests/expr/arith-divide-by-zero.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# XXX This file should test floats but #6474 needs to be fixed first.
spq: values a/b, a%b

vector: true
Expand All @@ -14,3 +15,17 @@ output: |
null::uint64
error("divide by zero")
error("divide by zero")

---

# Check the divide by zero logic on a const null returns a null.
spq: |
values
1/null::int64,
1::uint64/null::uint64

vector: true

output: |
null::int64
null::uint64
2 changes: 1 addition & 1 deletion vector/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func BoolValue(vec Any, slot uint32) (bool, bool) {
case *Bool:
return vec.Bits.IsSet(slot), vec.Nulls.IsSet(slot)
case *Const:
return vec.Value().Ptr().AsBool(), vec.Nulls.IsSet(slot)
return vec.Value().Ptr().AsBool(), vec.val.IsNull() || vec.Nulls.IsSet(slot)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really think this is the wrong approach and that the nulls vector should be the source of truth, with the implication that a vector.Const with a null super.Value should always have every bit set in its nulls vector.

Copy link
Collaborator Author

@mattnibs mattnibs Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly about this but I'd like to make sure this works someday in the near future. I can't assess whether what you are proposing is a quick fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out #6477.

case *Dict:
if vec.Nulls.IsSet(slot) {
return false, true
Expand Down
2 changes: 1 addition & 1 deletion vector/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func BytesValue(val Any, slot uint32) ([]byte, bool) {
return nil, true
}
s, _ := val.AsBytes()
return s, false
return s, val.val.IsNull()
case *Dict:
if val.Nulls.IsSet(slot) {
return nil, true
Expand Down
2 changes: 1 addition & 1 deletion vector/float.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func FloatValue(vec Any, slot uint32) (float64, bool) {
case *Float:
return vec.Value(slot), vec.Nulls.IsSet(slot)
case *Const:
return vec.Value().Ptr().Float(), vec.Nulls.IsSet(slot)
return vec.Value().Ptr().Float(), vec.val.IsNull() || vec.Nulls.IsSet(slot)
case *Dict:
if vec.Nulls.IsSet(slot) {
return 0, true
Expand Down
2 changes: 1 addition & 1 deletion vector/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func IntValue(vec Any, slot uint32) (int64, bool) {
case *Int:
return vec.Value(slot), vec.Nulls.IsSet(slot)
case *Const:
return vec.val.Int(), vec.Nulls.IsSet(slot)
return vec.val.Int(), vec.val.IsNull() || vec.Nulls.IsSet(slot)
case *Dict:
if vec.Nulls.IsSet(slot) {
return 0, true
Expand Down
2 changes: 1 addition & 1 deletion vector/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func IPValue(val Any, slot uint32) (netip.Addr, bool) {
return netip.Addr{}, true
}
b, _ := val.AsBytes()
return super.DecodeIP(b), false
return super.DecodeIP(b), val.val.IsNull()
case *Dict:
if val.Nulls.IsSet(slot) {
return netip.Addr{}, true
Expand Down
2 changes: 1 addition & 1 deletion vector/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NetValue(val Any, slot uint32) (netip.Prefix, bool) {
return netip.Prefix{}, true
}
s, _ := val.AsBytes()
return super.DecodeNet(s), false
return super.DecodeNet(s), val.val.IsNull()
case *Dict:
if val.Nulls.IsSet(slot) {
return netip.Prefix{}, true
Expand Down
2 changes: 1 addition & 1 deletion vector/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func StringValue(val Any, slot uint32) (string, bool) {
return "", true
}
s, _ := val.AsString()
return s, false
return s, val.val.IsNull()
case *Dict:
if val.Nulls.IsSet(slot) {
return "", true
Expand Down
2 changes: 1 addition & 1 deletion vector/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TypeValueValue(val Any, slot uint32) ([]byte, bool) {
return nil, true
}
s, _ := val.AsBytes()
return s, false
return s, val.val.IsNull()
case *Dict:
if val.Nulls.IsSet(slot) {
return nil, true
Expand Down
2 changes: 1 addition & 1 deletion vector/uint.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func UintValue(vec Any, slot uint32) (uint64, bool) {
case *Uint:
return vec.Value(slot), vec.Nulls.IsSet(slot)
case *Const:
return vec.Value().Ptr().Uint(), vec.Nulls.IsSet(slot)
return vec.Value().Ptr().Uint(), vec.val.IsNull() || vec.Nulls.IsSet(slot)
case *Dict:
if vec.Nulls.IsSet(slot) {
return 0, true
Expand Down