Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
52381: sql: improve overload selection when multiple candidates require the same type r=RaduBerinde a=RaduBerinde Our type checking cannot deal with expression `('{"x": "bar"}') -> 'x'`. This works without the parens because literal constants are treated as a special case. It used to work with parens because of some constant folding that was done before type-checking (which was removed). A principled fix would require big changes in type-checking. However, I did notice that some of the logic for filtering overloads is too restrictive. We only try to `TypeCheck` binary op arguments with a specific type when we have a single candidate overload left. This is why we don't try to type-check `('{"x": "bar"}')` as a Jsonb. This change improves this heuristic: instead of checking whether we have a single remaining candidate, check if all remaining candidates require the same type for that argument. This is a net improvement that happens to help in this particular case (where we have two variants for `->`, both taking a Jsonb on the left). Fixes cockroachdb#52043. Release note: None Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
- Loading branch information