sql: correctly type CASE expressions that result in tuples #78331
Labels
A-sql-typing
SQLtype inference, typing rules, type compatibility.
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
T-sql-foundations
SQL Foundations Team (formerly SQL Schema + SQL Sessions)
T-sql-queries
SQL Queries Team
Consider the query:
As of 22.1, the query results in an error:
The
CASE
is typed as atuple{string, int}
and theNULL::RECORD
is typed astypes.AnyTuple
(what theRECORD
type resolves to). The error occurs because there is no valid case fromtypes.AnyTuple
to any specific tuple type. The fix is to type theCASE
expression astypes.AnyTuple
, following the logic described in Postgres's type conversion documentation:Here's another example that errors in CRDB but succeeds in Postgres:
The error suggests that some changes to the parser might be required in order to get this working correctly.
Epic CRDB-2474
Jira issue: CRDB-14072
The text was updated successfully, but these errors were encountered: