-
Notifications
You must be signed in to change notification settings - Fork 117
Add CASE expression documentation #3763
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
Add CASE expression documentation #3763
Conversation
cc0b3f6 to
ac14356
Compare
- Changed Simple CASE syntax to Searched CASE (explicitly using WHEN conditions) - Updated supported_version from 4.3.2.0 to 4.7.2.0 - Removed test cases and documentation examples that expose product limitations: * CASE without ELSE (returns NULL) - only NULL rows returned with ORDER BY * CASE in WHERE clause - "expected BooleanValue but got PickValue" error * CASE in ORDER BY - UnableToPlanException - All remaining CASE tests now pass (basic CASE with ELSE clause)
ac14356 to
46ae200
Compare
…rie/fdb-record-layer into docs/case-when-documentation
| All result expressions in a CASE statement must return compatible types. | ||
| Mixing types (e.g., strings and numbers) will cause an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could a result be NULL and be compatible to other results? If it so, then we can avoid writing that case altogether, and not have ELSE; but just curious if the former is possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, a result can be NULL. It could still make sense to write that case down, since you may want it to be evaluated before some of the later cases though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we need to have an explicit example for that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is documented in the Evaluation Order section
yaml-tests/src/test/resources/documentation-queries/case-documentation-queries.yamsql
Outdated
Show resolved
Hide resolved
|
|
||
| All result expressions must be of compatible types (or NULL). | ||
|
|
||
| Examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we also need an example of the CASE construct in SELECT and ORDER BY clauses (as indicated in PR desc)? (I didn't know we could use it in ORDER BY (can we?), and how that would look!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two examples with CASE constructs in SELECT (Value Matching with CASE, and Nested CASE).
The ORDER BY case is totally not supported, I'll remove that from the description.
We essentially cannot generate an index with a dispatch as part of a KeyExpression at the moment, therefore we cannot plan an order by query with that.
Updated section headings and removed redundant text in the CASE documentation.
g31pranjal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor suggestions for tests – but since the documentation looks good and complete, 👍
| name: case-documentation-tests | ||
| preset: single_repetition_ordered | ||
| tests: | ||
| # Searched CASE - Simple condition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify this as well?
| {name: "Widget A", stock: 50, stock_status: "Well Stocked"}, | ||
| {name: "Widget B", stock: 5, stock_status: "Low Stock"}] | ||
|
|
||
| # Simple CASE - Value matching |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
| All result expressions in a CASE statement must return compatible types. | ||
| Mixing types (e.g., strings and numbers) will cause an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we need to have an explicit example for that here?
Summary
Adds complete documentation for CASE expressions including both Simple and Searched forms.
Features documented