-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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: Add TRUNC alias for TRUNCATE #49571
Conversation
Add TRUNC as alias to already implemented TRUNCATE numeric function which is the flavour supported by Oracle and PostgreSQL. Relates to: elastic#41195
Pinging @elastic/es-search (:Search/SQL) |
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.
LGTM
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.
LGTM
@@ -385,7 +385,7 @@ include-tagged::{sql-specs}/docs/docs.csv-spec[mathInlineSqrt] | |||
-------------------------------------------------- | |||
|
|||
[[sql-functions-math-truncate]] | |||
==== `TRUNCATE` | |||
==== `TRUNCATE/TRUNC` |
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.
Shouldn't be TRUNC/TRUNCATE
(alphabetical order)?
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.
In general, we don't do it alphabetically here, for example: DAY_OF_MONTH/DOM/DAY
@astefan, what do you think?
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.
Seems indeed a mixed usage: CEIL/CEILING
, but also RANDOM/RAND
.
Fwiw, I find the "short/long" version easier to read (i.e. visually take in), but unless we order them all like that, this one case is not very relevant.
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 was thinking also that TRUNCATE was already there, if we put TRUNC first we will need to also change the definition paragraph and use TRUNC instead (we always use the 1st version there).
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.
The initial implementation for RANDOM and TRUNCATE came from https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/numeric-functions?view=sql-server-2017, where they are indeed called like that. I agree with Marios here: in our docs the first name is the "main" one and the rest are aliases. For consistency, I would go with TRUNCATE/TRUNC, RANDOM/RAND etc. The biggest counter-example to the "alphabetical" approach is the series of DOM/DOY/DOW/DAYNAME aliases for some of the date/datetime functions.
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.
LGTM
Add TRUNC as alias to already implemented TRUNCATE
numeric function which is the flavour supported by
Oracle and PostgreSQL.
Relates to: #41195