-
Notifications
You must be signed in to change notification settings - Fork 113
Add documentation to CAST
operator.
#3668
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
base: main
Are you sure you want to change the base?
Conversation
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.
Looks good overall!
I left a couple of comments.
|
||
.. code-block:: sql | ||
|
||
CAST(expression AS target_type) |
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.
To remain consistent with the rest of the doc, you'd want to put a railroad diagram here.
The value or expression to be converted. | ||
|
||
* :sql:`target_type` | ||
The target data type. Can be a primitive type (:sql:`INT`, :sql:`LONG`, :sql:`FLOAT`, :sql:`DOUBLE`, :sql:`STRING`, :sql:`BOOLEAN`) or an array type (e.g., :sql:`INTEGER ARRAY`, :sql:`STRING ARRAY`). |
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.
INT and LONG should be replaced by INTEGER and BIGINT throughout the document
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.
Done.
Boolean Conversions | ||
------------------- | ||
|
||
* :sql:`BOOLEAN` ↔ :sql:`INT`: true = 1, false = 0 |
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.
This is probably a uni-directional arrow, given the fact that the other direction is written the line underneath.
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.
Nice catch, done.
INSERT INTO data VALUES (1, 'invalid') | ||
|
||
SELECT CAST(str_value AS INTEGER) FROM data WHERE id = 1 | ||
-- Error: Cannot cast string 'invalid' to :sql:`INT` |
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.
Is that the actual error message?
I guess the error message should not contain :sql:
since this is a RST thing.
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.
Yeah, the exact error message is: Value out of range for INT
. There is something to be said about rewriting error messages originating from the Cascades types system validations and the upper relational layer SQL types., and overall consistency of SQL error messages, as in e.g. #3583.
Looks like you had a search replace mishap, can you fix that? |
You're right, I reverted the newly invented type |
With #3647 we introduce support for
CAST
operator, this adds documentation of this operator, including supported casts, error codes, and degree of compliance to the SQL standard.This fixes #3662.