-
Notifications
You must be signed in to change notification settings - Fork 25.5k
ES|QL: Add TRANGE ES|QL function #136441
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: main
Are you sure you want to change the base?
ES|QL: Add TRANGE ES|QL function #136441
Conversation
Add a new ES|QL function that filters @timestamp values for the given time range. Closes elastic#135599
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
Hi @leontyevdv, I've created a changelog YAML for you. |
🔍 Preview links for changed docs |
ℹ️ 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 overviewWhen to use applies_to tags:✅ At the page level to indicate which products/deployments the content applies to (mandatory) What NOT to do:❌ Don't remove or replace information that applies to an older version 🤔 Need help?
|
Add a new ES|QL function that filters @timestamp values for the given time range. Closes elastic#135599
Thank you, Dima! Is there a reason we don't translate TRANGE to GreaterThanEquals() or BinaryLogicOperation(GreaterThanEquals, LessThanOrEquals)? |
Hi @dnhatn ! Thank you for the review! Initially, I implemented TRANGE as a surrogate and struggled with the tests for quite a while. The issue was with the assertion ("Duplicate name ids are not allowed in layouts"): see Layout. Then, inspired by the StartsWith function, I rewrote it using TranslationAware.SingleValueTranslationAware directly. I have the surrogate version in my stash. We can take a look at it together. Wdyt? |
Fix tests. Closes elastic#135599
# Conflicts: # x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries-rate.csv-spec # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
Add a new ES|QL function that filters @timestamp values for the given time range.
Filters
@timestamp
values for the given time range. The first version implicitly uses now() as end time, giving an interval for the last hour or day, while the second one can consume regular DateTime specs or negative intervals:TRANGE(1h)
is equivalent to@timestamp >= now() - 1 hour
TRANGE(-3h, -2h)
is equivalent to@timestamp >= now() - 3 hour AND @timestamp < now() - 2h
TRANGE(2024-05-12T12:00:00, 2024-05-12T15:30:00)
is equivalent to@timestamp >= DATE_PARSE(2024-05-12T12:00:00) AND @timestamp < DATE_PARSE(2024-05-12T15:30:00)
TRANGE(1715504400000, 1715517000000)
is equivalent to the above, using ms since Epoch instead of text-formatted dates.Closes #135599