sql: don't re-write CAST
s to 'list's with the ::
operator
#31696
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes our SQL rendering to use the standard SQL
CAST
expression when a cast involves thelist
type, instead of rewriting the expression to use the Postgres::
operator.The rewrite to the Postgres operator was originally introduced in #3149
I went back and forth on a number of different solutions to fix this panic, and what's in this PR is sort of the least bad. My major gripe with this implementation is adding the
AstDataType
trait, it feels like it breaks the abstraction ofAstInfo::DataType
, but maybe this isn't too bad?Other changes I tried:
int list[]
as indexing into a list as opposed to the typeArray<List<int>>
. We already don't support arrays of lists, but this behavior felt like a very big change.(int list)
. Also not a bad solution but the parser impl wasn't too straight forward, and given the root cause was re-writing theCAST
statements, this felt like a bit of a hack?::
expression in parens, e.g.((<field>)::<type> list)[index]
. But this also changes the semantics a bit because now the expression provided to the subscript operator is a nested expression. Concretely going from text -> AST -> text -> AST failed to roundtrip AST.Motivation
A customer hit this panic in their environment.
Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.