Skip to content
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

Merged
merged 1 commit into from
Nov 26, 2019
Merged

Conversation

matriv
Copy link
Contributor

@matriv matriv commented Nov 25, 2019

Add TRUNC as alias to already implemented TRUNCATE
numeric function which is the flavour supported by
Oracle and PostgreSQL.

Relates to: #41195

Add TRUNC as alias to already implemented TRUNCATE
numeric function which is the flavour supported by
Oracle and PostgreSQL.

Relates to: elastic#41195
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/SQL)

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

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

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

LGTM

@matriv matriv merged commit f2aa7f0 into elastic:master Nov 26, 2019
@matriv matriv deleted the add-trunc-alias branch November 26, 2019 11:30
matriv added a commit that referenced this pull request Nov 26, 2019
Add TRUNC as alias to already implemented TRUNCATE
numeric function which is the flavour supported by
Oracle and PostgreSQL.

Relates to: #41195

(cherry picked from commit f2aa7f0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants