Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: improve type checking error messages with AnnotateTypeExpr of NULL #78335

Open
Tracked by #75101
mgartner opened this issue Mar 23, 2022 · 0 comments
Open
Tracked by #75101
Labels
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

Comments

@mgartner
Copy link
Collaborator

mgartner commented Mar 23, 2022

The expression NULL:::T (a NULL value annotated as type T) can lead to confusing error messages. This is because when the expression is type-checked, a tree.DNull value is returned, which includes no information about the annotated type T - the resolved type of tree.DNull is always types.Unknown. An expression that contains an annotated NULL and fails type checking often has a confusing error message as a result.

For example, notice that the error message below states "found type unknown", when "found type int" would make more sense:

defaultdb> SELECT CASE WHEN true THEN ('a', 2) ELSE NULL:::INT END;
ERROR: incompatible value type: expected NULL:::INT8 to be of type tuple, found type unknown

Epic CRDB-2474
Jira issue: CRDB-14073

@mgartner mgartner added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Mar 23, 2022
@mgartner mgartner added this to Triage in SQL Sessions - Deprecated via automation Mar 23, 2022
@mgartner mgartner added this to Triage in SQL Queries via automation Mar 23, 2022
@mgartner mgartner moved this from Triage to Longer term backlog in SQL Sessions - Deprecated Mar 23, 2022
@mgartner mgartner moved this from Triage to Backlog in SQL Queries Mar 23, 2022
@blathers-crl blathers-crl bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) T-sql-queries SQL Queries Team labels Mar 23, 2022
@exalate-issue-sync exalate-issue-sync bot removed the T-sql-queries SQL Queries Team label Aug 25, 2022
@yuzefovich yuzefovich added the T-sql-queries SQL Queries Team label May 2, 2024
@exalate-issue-sync exalate-issue-sync bot removed the T-sql-queries SQL Queries Team label May 2, 2024
@yuzefovich yuzefovich added the T-sql-queries SQL Queries Team label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Projects
Status: Backlog
SQL Queries
Backlog (DO NOT ADD NEW ISSUES)
SQL Sessions - Deprecated
Longer term backlog
Development

No branches or pull requests

2 participants