Skip to content

Conversation

felixbarny
Copy link
Member

Allows ES|QL queries like this:

FROM logs-* | WHERE @timestamp > now() - 1m

There's a potential ambiguity with month but m is commonly used in other query languages to mean minutes so I think that's essentially common practice.

Today, we don't support m and a query would fail with Unexpected temporal unit: 'm'. So this change is not breaking existing behavior.

Closes #135552

@felixbarny felixbarny added the :Analytics/ES|QL AKA ESQL label Oct 11, 2025
@elasticsearchmachine elasticsearchmachine added v9.3.0 Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) labels Oct 11, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the external-contributor Pull request authored by a developer outside the Elasticsearch team label Oct 11, 2025
Copy link
Contributor

github-actions bot commented Oct 11, 2025

🔍 Preview links for changed docs

Copy link
Contributor

ℹ️ Important: Docs version tagging

👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version.

We use applies_to tags to mark version-specific features and changes.

Expand for a quick overview

When to use applies_to tags:

✅ At the page level to indicate which products/deployments the content applies to (mandatory)
✅ When features change state (e.g. preview, ga) in a specific version
✅ When availability differs across deployments and environments

What NOT to do:

❌ Don't remove or replace information that applies to an older version
❌ Don't add new information that applies to a specific version without an applies_to tag
❌ Don't forget that applies_to tags can be used at the page, section, and inline level

🤔 Need help?

@elasticsearchmachine
Copy link
Collaborator

Hi @felixbarny, I've created a changelog YAML for you.

@felixbarny
Copy link
Member Author

felixbarny commented Oct 11, 2025

Note that the DATE_DIFF function treats m as month, not minute, so this would introduce a small inconsistency. Given the prevalence of m meaning minutes in other query languages, and the fact that duration literals and date_diff support different values, I think that small consistency is probably fine.

However, we can think about de-emphasizing or deprecating m to mean month in date_diff. For example, we could remove it from the documentation while still supporting it.

@felixbarny
Copy link
Member Author

See also this note from the date_diff docs:

Note that while there is an overlap between the function’s supported units and ES|QL’s supported time span literals, these sets are distinct and not interchangeable.

Seems like it's fine that the date_diff and time span/duration units differ.

@felixbarny felixbarny requested a review from costin October 11, 2025 08:29
@costin costin requested a review from bpintea October 12, 2025 23:44
@costin
Copy link
Member

costin commented Oct 12, 2025

LGTM, adding @bpintea since he's been working in this area and for awareness of the m usage in DATE_DIFF.

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.

👍

@costin costin removed the external-contributor Pull request authored by a developer outside the Elasticsearch team label Oct 12, 2025
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.

Except for a comment, it LGTM.

m isn't quite unambiguous, unfortunately. Worse off, we have a DATE_DIFF function that uses its own set of units and uses m for month, inline with other SQL implementations of the similar function, like MS SQL. (And the conflict/confusion shows already, like in #136426, despite our docs clarification). But I guess we can assume that minute has a higher usage generally and prioritise it.

@felixbarny felixbarny enabled auto-merge (squash) October 13, 2025 13:37
@felixbarny felixbarny merged commit de66849 into elastic:main Oct 13, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add m as an alias to minute time duration

4 participants