Skip to content

ESQL: Forbid SET nullify and load for implicit @timestamp field#144239

Merged
astefan merged 11 commits intoelastic:mainfrom
astefan:142127_implementation
Mar 19, 2026
Merged

ESQL: Forbid SET nullify and load for implicit @timestamp field#144239
astefan merged 11 commits intoelastic:mainfrom
astefan:142127_implementation

Conversation

@astefan
Copy link
Copy Markdown
Contributor

@astefan astefan commented Mar 13, 2026

Addresses #142127

@astefan astefan force-pushed the 142127_implementation branch from 6cfd6c1 to fdfb130 Compare March 17, 2026 09:13
@astefan astefan marked this pull request as ready for review March 17, 2026 09:14
@astefan astefan requested review from alex-spies and kkrik-es March 17, 2026 09:14
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Mar 17, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@astefan astefan requested a review from GalLalouche March 18, 2026 07:26
assert partialMetrics != null;
Failures failures = new Failures();

boolean unmappedTimestampHandled = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider:

unmappedTimestampHandled = unmappedResolution == UnmappedResolution.FAIL || checkUnmappedTimestamp(plan, failures)

* if the field was present but dropped/renamed by the query, the generic unresolved-attribute message is more appropriate.
* See https://github.com/elastic/elasticsearch/issues/142127
*/
private static boolean checkUnmappedTimestamp(LogicalPlan plan, Failures failures) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this method should be renamed so it's clear what it's actually returning, e.g., isTimestampUnmappedInAllIndices or something to that effect.

);
}

private void unmappedTimestampFailure(String query, String... expectedFailures) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like you're always appending the suffix to the expectedFailures. Why not just do it in this method instead of in all the other places?


public void testTbucketWithTimestampPresent() {
for (var statement : List.of(
setUnmappedNullify("FROM sample_data | STATS c = COUNT(*) BY tbucket(1 hour)"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Extract common query.

}

public void testTrangeWithTimestampPresent() {
for (var statement : List.of(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Extract common query.

@astefan astefan requested a review from GalLalouche March 18, 2026 13:47
@astefan astefan added auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) and removed auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) labels Mar 18, 2026
@astefan astefan requested review from dnhatn and removed request for alex-spies and kkrik-es March 18, 2026 16:48
Copy link
Copy Markdown
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

Since TBUCKET is syntactic sugar for BUCKET(@timestamp, ...), I'd expect similar behavior from both. However, there's separate timestamp validation in time-series aggregation, I'm okay with this change. Thanks Andrei!

@astefan astefan merged commit fdfbbc3 into elastic:main Mar 19, 2026
28 checks passed
@astefan
Copy link
Copy Markdown
Contributor Author

astefan commented Mar 19, 2026

Thank you @GalLalouche @dnhatn for the reviews 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants