-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Docs: move type conversion functions to source (2/3) #87046
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: master
Are you sure you want to change the base?
Conversation
Workflow [PR], commit [37e4e6c] Summary: ❌
|
…o type_conversion_functions_2
factory.registerFunction<FunctionReinterpret>(); | ||
FunctionDocumentation::Description description_reinterpretAsUInt8 = R"( | ||
Performs byte reinterpretation by treating the input value as a value of type UInt8. | ||
Unlike [`CAST`](#cast), the function does not attempt to preserve the original value - if the target type is not able to represent the input type, the output is meaningless. |
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.
meaningless
--> undefined
|
||
factory.registerFunction<FunctionReinterpret>(); | ||
FunctionDocumentation::Description description_reinterpretAsUInt8 = R"( | ||
Performs byte reinterpretation by treating the input value as a value of type UInt8. |
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.
Simpler: Reinterprets the input value as a value of type UInt8.
In l. 544: Value to reinterpret as UInt8.
Please apply the same kind of changes also for the other functions in this file.
"Usage example", | ||
R"( | ||
SELECT | ||
toInt8(257) AS x, |
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.
Strange example. toInt8(257)
produces an internal overflow.
Can we do this (basically the same example as in docs of function CAST):
SELECT
toInt8(-1) AS val,
toTypeName(val),
reinterpretAsUInt8(val) AS res,
toTypeName(res);
?
There will still be an overflow but during re-interpretation as UInt8 ... which is what the description above warns about.
factory.registerFunction<FunctionReinterpretAsFloat64>(documentation_reinterpretAsFloat64); | ||
|
||
FunctionDocumentation::Description description_reinterpretAsDate = R"( | ||
Accepts a string, fixed string or numeric value and interprets the bytes as a number in host order (little endian). It returns a date from the interpreted number as the number of days since the beginning of the Unix Epoch. |
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.
Just: Reinterprets the input value as a
Date value (assuming little endian order) which is the number of days since the beginning of the Unix epoch 1970-01-01
.
factory.registerFunction<FunctionReinterpretAsDate>(documentation_reinterpretAsDate); | ||
|
||
FunctionDocumentation::Description description_reinterpretAsDateTime = R"( | ||
These functions accept a string and interpret the bytes placed at the beginning of the string as a number in host order (little endian). Returns a date with time interpreted as the number of seconds since the beginning of the Unix Epoch. |
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.
.
factory.registerFunction<FunctionReinterpretAsUUID>(documentation_reinterpretAsUUID); | ||
|
||
FunctionDocumentation::Description description_reinterpretAsString = R"( | ||
This function accepts a number, date or date with time and returns a string containing bytes representing the corresponding value in host order (little endian). Null bytes are dropped from the end. For example, a UInt32 type value of 255 is a string that is one byte long. |
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.
Reinterprets the input value as a string (assuming little endian order). Null bytes at the end are ignored, for example, the function returns for UInt32 value 255 a string with a single character.
Splits #86839.
Moves type conversion functions docs into the source code. Part 2/3.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes