Skip to content

Conversation

fang-xing-esql
Copy link
Member

@fang-xing-esql fang-xing-esql commented Nov 7, 2024

Resolves: #112592

We have some descriptions of timespan literals here in the ES|QL syntax page, https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-syntax.html#esql-timespan-literals

This PR is to have a central place to document the usages of date_period and time_duration with more examples, so that users have a general idea about how they are used in various places in ES|QL.

@fang-xing-esql fang-xing-esql added >docs General docs changes :Analytics/ES|QL AKA ESQL v9.0.0 labels Nov 7, 2024
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Documentation preview:

@fang-xing-esql fang-xing-esql marked this pull request as ready for review November 8, 2024 19:00
@elasticsearchmachine elasticsearchmachine added Team:Docs Meta label for docs team Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) labels Nov 8, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-docs (Team:Docs)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

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.

IMO, if we introduce a detailed chapter on this (which is great), we can shorten the corresponding paragraph in the syntax reference by skipping the list of supported temporal units and linking in the table from the new chapter?

Also, adding some implicit casting examples would be useful (once that's merged).

@fang-xing-esql
Copy link
Member Author

IMO, if we introduce a detailed chapter on this (which is great), we can shorten the corresponding paragraph in the syntax reference by skipping the list of supported temporal units and linking in the table from the new chapter?

Also, adding some implicit casting examples would be useful (once that's merged).

Thanks for reviewing @bpintea! I just realized that I didn't update #115814 with your suggestions on the implicit casting docs, my bad, so I include them(implicit-casting.asciidoc) in this doc PR.

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

@fang-xing-esql
Copy link
Member Author

Lgtm

Thank you for reviewing @bpintea! I'll wait for @leemthompo to take a final look before merging it.

@fang-xing-esql fang-xing-esql added v8.17.0 auto-backport Automatically create backport pull requests when merged labels Nov 18, 2024
Copy link
Contributor

@leemthompo leemthompo left a comment

Choose a reason for hiding this comment

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

Looks good! Few suggested copyedits from me, will check the URL preview again once updates are made, feel free to ping for re-review :)


Time spans are often used in datetime related grouping functions like <<esql-bucket, BUCKET>>, scalar functions like <<esql-date_trunc, DATE_TRUNC>> and arithmetic operators like <<esql-add, `+`>> and <<esql-subtract, `-`>>. There are conversions functions that can convert string literals to time spans, <<esql-to_dateperiod, TO_DATEPERIOD>>, <<esql-to_timeduration, TO_TIMEDURATION>> and their corresponding <<esql-cast-operator, cast operators>> `::DATE_PERIOD` and `::TIME_DURATION`.

==== Examples of using time spans in {esql}
Copy link
Contributor

@leemthompo leemthompo Nov 18, 2024

Choose a reason for hiding this comment

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

Suggested change
==== Examples of using time spans in {esql}
[discrete]
[[esql-time-spans-examples]]
==== Examples of using time spans in {esql}

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean [[esql-time-spans-examples]] here? [[esql-time-spans]] has already been used at the beginning of this file.

Copy link
Contributor

@leemthompo leemthompo Nov 19, 2024

Choose a reason for hiding this comment

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

certainly did! fixed suggestion :)

@fang-xing-esql
Copy link
Member Author

Looks good! Few suggested copyedits from me, will check the URL preview again once updates are made, feel free to ping for re-review :)

Thank you for reviewing @leemthompo ! I have updated the branch with your comments, could you help take a look again when you get a chance?

Copy link
Contributor

@leemthompo leemthompo left a comment

Choose a reason for hiding this comment

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

LGTM

@fang-xing-esql fang-xing-esql merged commit d33bff6 into elastic:main Nov 19, 2024
5 checks passed
fang-xing-esql added a commit to fang-xing-esql/Elasticsearch that referenced this pull request Nov 19, 2024
elasticsearchmachine pushed a commit that referenced this pull request Nov 19, 2024
rjernst pushed a commit to rjernst/elasticsearch that referenced this pull request Nov 20, 2024
alexey-ivanov-es pushed a commit to alexey-ivanov-es/elasticsearch that referenced this pull request Nov 28, 2024
@fang-xing-esql fang-xing-esql deleted the time-spans-doc branch December 5, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged >docs General docs changes Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Docs Meta label for docs team v8.17.0 v9.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ES|QL: document date_period and time_duration data types

4 participants