Skip to content

Conversation

@arnaud-lacurie
Copy link
Collaborator

@arnaud-lacurie arnaud-lacurie commented Nov 17, 2025

Summary

Adds complete documentation for CASE expressions including both Simple and Searched forms.

Features documented

  • Conditional evaluation with WHEN/THEN/ELSE
  • CASE in SELECT and WHERE clause.
  • Nested CASE expressions
  • NULL handling and type compatibility

@arnaud-lacurie arnaud-lacurie added the documentation Documentation change label Nov 17, 2025
@arnaud-lacurie arnaud-lacurie force-pushed the docs/case-when-documentation branch from cc0b3f6 to ac14356 Compare November 18, 2025 00:00
- 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)
@arnaud-lacurie arnaud-lacurie force-pushed the docs/case-when-documentation branch from ac14356 to 46ae200 Compare November 18, 2025 00:07
@arnaud-lacurie arnaud-lacurie marked this pull request as ready for review November 24, 2025 18:30
Comment on lines +284 to +285
All result expressions in a CASE statement must return compatible types.
Mixing types (e.g., strings and numbers) will cause an error.
Copy link
Member

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

Copy link
Collaborator Author

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.

Copy link
Member

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?

Copy link
Collaborator Author

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


All result expressions must be of compatible types (or NULL).

Examples
Copy link
Member

@g31pranjal g31pranjal Nov 27, 2025

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!)

Copy link
Collaborator Author

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.
Copy link
Member

@g31pranjal g31pranjal left a 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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines +284 to +285
All result expressions in a CASE statement must return compatible types.
Mixing types (e.g., strings and numbers) will cause an error.
Copy link
Member

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?

@arnaud-lacurie arnaud-lacurie merged commit beb4176 into FoundationDB:main Nov 28, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants