Skip to content

Conversation

@not-napoleon
Copy link
Member

Add CSV tests for invalid ranges (i.e. where the lower bound is greater than the upper bound) for several data types. It looks at first glance like there should be a bug here with Date Nanos, but I cannot trigger one, and analysis suggests the code that has the bug is in fact unreachable. I've left comments to that effect.

@not-napoleon not-napoleon added >test Issues or PRs that are addressing/adding tests auto-backport Automatically create backport pull requests when merged :Analytics/ES|QL AKA ESQL v8.19.0 v9.1.0 labels Mar 26, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Mar 26, 2025
Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

LGTM. More tests always nice and adds a notice to this code.

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.

/cc @bpintea - can you please take a look at this (potentially in a follow-up)?

*/
protected boolean areBoundariesInvalid(Object lowerValue, Object upperValue) {
/*
NB: I am reasonably sure this code is dead. It can only be reached from foldable(), and as far as I can tell
Copy link
Contributor

Choose a reason for hiding this comment

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

++, I think this is a leftover from ql as we shouldn't represent datetimes as strings inside esql, not even in literals.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the only reason to keep this code at all is because Range should satisfy the contract of expressions, which includes foldability. But we could also just yeet this as we just never reach here.

Copy link
Contributor

Choose a reason for hiding this comment

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

the only reason to keep this code at all is because Range should satisfy the contract of expressions, which includes foldability.

We could just throw, like the serialisation method does. But: it'd be great if we decided on supporting range syntax in the language first (issue).
We've had an attempt to bring Range into the logical planning, but eventually settled for the current, more pragmatic approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

That issue has been open for a year and a half. As far as I know, it's not planned currently, and it isn't clear that we even want to add that syntax. In the meantime, having to work around dead code adds cognitive load and extra work. If we decide we need that syntax, and that the original logic here is important, we can always find it in the git history.

Copy link
Contributor

Choose a reason for hiding this comment

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

having to work around dead code adds cognitive load and extra work

I agree. I was thinking that knowing to look for removed code (and where) is harder than deciding we don't want this syntax and just remove the code already.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also think removing this dead code is the right thing to do. I'd be happy to do so, either in this PR or in a follow up, if we're in agreement that we should.

Comment on lines +161 to +162
PushFiltersToSource can also create ranges, but that is a Physical optimizer rule. Folding happens in the
Logical optimization layer, and should be done by the time we are calling PushFiltersToSource.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding this comment, I think the reasoning is solid.

Copy link
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

Thanks a lot @not-napoleon , more tests + very useful comments, I appreciate that a lot!


// Equals OR Range
/*
NB: this loop is probably dead code. There's no syntax for ranges, so the parser never produces them. This
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, just in case any other changes will be added to the PR:

Suggested change
NB: this loop is probably dead code. There's no syntax for ranges, so the parser never produces them. This
NB: this loop is currently dead code. There's no syntax for ranges, so the parser never produces them. This

The "dead code" note in Range.java can be spotted and updated if we bring more Range support in the language, this one might not be as visible.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not really sure what you're suggesting I do about making this more visible

Copy link
Contributor

Choose a reason for hiding this comment

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

My comment was about the possibility of us extending Range support and this comment becoming inaccurate (well, despite the "probably" disclaimer). Not terribly important, can be merged as is.

Copy link
Member

Choose a reason for hiding this comment

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

I think the three of us think this is dead code. Should we just remove it?

@bpintea
Copy link
Contributor

bpintea commented Mar 27, 2025

/cc @bpintea - can you please take a look at this (potentially in a follow-up)?

Sure, but it might be good to decide first if we'll want to give up on BETWEEN (as hinted above).

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.

🙏 for the comments.

@not-napoleon not-napoleon enabled auto-merge (squash) March 27, 2025 17:24
@not-napoleon not-napoleon merged commit 27ebb14 into elastic:main Mar 28, 2025
15 of 17 checks passed
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.x

not-napoleon added a commit to not-napoleon/elasticsearch that referenced this pull request Mar 28, 2025
Add CSV tests for invalid ranges (i.e. where the lower bound is greater than the upper bound) for several data types. It looks at first glance like there should be a bug here with Date Nanos, but I cannot trigger one, and analysis suggests the code that has the bug is in fact unreachable. I've left comments to that effect.
omricohenn pushed a commit to omricohenn/elasticsearch that referenced this pull request Mar 28, 2025
Add CSV tests for invalid ranges (i.e. where the lower bound is greater than the upper bound) for several data types. It looks at first glance like there should be a bug here with Date Nanos, but I cannot trigger one, and analysis suggests the code that has the bug is in fact unreachable. I've left comments to that effect.
elasticsearchmachine pushed a commit that referenced this pull request Mar 31, 2025
* ESQL - CSV tests for invalid ranges (#125714)

Add CSV tests for invalid ranges (i.e. where the lower bound is greater than the upper bound) for several data types. It looks at first glance like there should be a bug here with Date Nanos, but I cannot trigger one, and analysis suggests the code that has the bug is in fact unreachable. I've left comments to that effect.

* add capability checks
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 Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) >test Issues or PRs that are addressing/adding tests v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants