Types and unwrapping panics #6972
Replies: 3 comments
-
I'm not sure I follow, @frankmcsherry. Our implementation of SQL is statically typed; SQL queries that are not well-typed are rejected before they are lowed to IR. It's true that bugs in our type checker/IR transformations (or miscommunications between the two) can cause type errors at runtime... but that's morally equivalent to bugs in LLVM that generate invalid assembly for valid C code, isn't it? I suspect we're going to want to make this problem worse over time, not better. I.e., datums have a discriminant, so I guess what I'm saying is it's not clear to me what more we could do. I realize that probably sounds pessimistic, and I'm definitely open to something more sophisticated! But short of formal verification it's not clear to me that there's anything else to do here besides test extensively, and we're already ahead of the curve on that. |
Beta Was this translation helpful? Give feedback.
-
Well, I suppose we could lean on the Rust compiler's type checker if we generated Rust code and compiled it via LLVM for every query, but that just trades one set of issues for another. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I should have put more context. This was from Zulip, and to satisfy the request that this be committed to the public record. It is not exactly a well-considered proposal for how to make the world better (not yet!). I think what I was getting at is that there are several opportunities for us (me, let's say) to get things wrong, and we could in principle work to minimize these. For example, we could unify No urgent failings that need to be fixed, but a gradient of footgun disarmament that we can idly consider. :D |
Beta Was this translation helpful? Give feedback.
-
Our use of dynamic typing (or .. no typing?) leads to some awkward moments where types are not right and it is a bit hard to immediately see why.
From Zulip:
Frank McSherry: @jamie Brandon I've not fully debugged this, but I'm seeing a panic in
unwrap_int32()
inwhere it claims we have a
Datum::Int64
as input. It could easily be some screw-up on my part, but is it expected that all the types are correct all the way through?Frank McSherry: Wait, NO! My fault sorry. It wasn't there, but rather that (elsewhere) I failed to wrap the output of
Count
asDatum::Int64
and had instead wrapped it asDatum::Int32
.This may just be an unavoidable pain of a language that needs to support a mix of numeric, boolean, and other (string) data in the same positions. However, anything we can think to do to detect these issues earlier might help.
Beta Was this translation helpful? Give feedback.
All reactions