Skip to content

Conversation

@yuancu
Copy link
Collaborator

@yuancu yuancu commented Nov 3, 2025

Description

This PR restores support for decimal in span literals for bin commad.

E.g. It makes the following queries possible

  • span used in timechart, bin, etc. E.g. source=events_null | bin cpu_usage span=7.5 | stats count() by cpu_usage
  • decimal for span used in stats. E.g. | stats span(value, 9.5)

Please note that the following items are not in scope as they were not supported:

  • decimal + time unit. E.g. | timechart span=0.95d

Related Issues

Resolves #4631

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

}

@Test
public void testBinWithDecimalSpan() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

is span(@timestamp, 0.5d) supported with this PR? please add an IT for that

Copy link
Member

Choose a reason for hiding this comment

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

Please note that the following items are not in scope as they were not supported:

  • decimal + time unit. E.g. | timechart span=0.95d
  • decimal for span used in stats. E.g. | stats span(value, 9.5)

What exception will be thrown in above PPLs, please add IT or UT for them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • Added a unit test for the error in the first use case

  • Restore support to the second case:

    • decimal for span used in stats. E.g. | stats span(value, 9.5)

@yuancu yuancu changed the title Support using decimal for span literal in bin command Support using decimal as span literals Nov 3, 2025
@yuancu yuancu marked this pull request as draft November 4, 2025 03:15
@yuancu yuancu marked this pull request as ready for review November 4, 2025 03:38
assertThrows(
SyntaxCheckException.class,
() -> plan("source=t | stats count by span(@timestamp, 2.5y)"));
assertTrue(t2.getMessage().contains("[y] is not a valid term at this part of the query"));
Copy link
Member

Choose a reason for hiding this comment

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

"[y] is not a valid term" is a confusing error message since user can use span(@timestamp, 1y)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. The error message becomes Span length [2.5y] is invalid: floating-point time intervals are not supported.

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

Labels

backport 2.19-dev bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Span cannot use float numbers

2 participants