You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
colbuilder: fix recently exposed type schema corruption
This commit fixes recently exposed (or introduced, depending on how you
look at this) type schema corruption that can occur when planning filter
expressions. In particular, the bug was exactly as the comment deleted
in 85fd4fb described:
```
// As an example, consider the following scenario in the context of
// planFilterExpr method:
// 1. r.ColumnTypes={types.Bool} with len=1 and cap=4
// 2. planSelectionOperators adds another types.Int column, so
// filterColumnTypes={types.Bool, types.Int} with len=2 and cap=4
// Crucially, it uses exact same underlying array as r.ColumnTypes
// uses.
// 3. we project out second column, so r.ColumnTypes={types.Bool}
// 4. later, we add another types.Float column, so
// r.ColumnTypes={types.Bool, types.Float}, but there is enough
// capacity in the array, so we simply overwrite the second slot
// with the new type which corrupts filterColumnTypes to become
// {types.Bool, types.Float}, and we can get into a runtime type
// mismatch situation.
```
More concretely, in `planFilterExpr` we are using the passed-in type
schema to append new types for the intermediate projection operators,
and then we create a "simple project op" that removes those intermediate
operators. If we later try to add more output columns, we will overwrite
types captured by the intermediate projected away operators. The bug was
that the simple project op did not create a new type schema like it's
supposed to do.
This is now fixed, and we now enforce that the simple project op in
`colbuilder` package can only be created by the helper method that
explicitly returns the updated type schema, hoping that this will
encourage the callers to think about the type schema management to
prevent such issues in the future.
Release note: None
0 commit comments