-
Notifications
You must be signed in to change notification settings - Fork 180
Support refering to implicit @timestamp field in span
#4138
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
Conversation
Signed-off-by: Yuanchun Shen <[email protected]>
…t specifying a field Signed-off-by: Yuanchun Shen <[email protected]>
LantaoJin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuancu can you fix the conflicts
Signed-off-by: Yuanchun Shen <[email protected]>
| public RexNode visitSpan(Span node, CalcitePlanContext context) { | ||
| RexNode field = analyze(node.getField(), context); | ||
| RexNode field; | ||
| if (node.getField() != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be better to set field in span to be new Field(new QualifiedName(OpenSearchConstants.IMPLICIT_FIELD_TIMESTAMP)) if field is null? Then we don't need any change here.
And I'm wondering if v2 works well since we only make change for calcite visitor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I referred it here because I thought the AST level should be consistent with users' input. E.g. BY span(1h) should be parsed to Span(value=1, unit=hour, field=null). Subsequent implicit reference can be added later because this semantic of how absent field should be interpreted is in a higher level than syntax tree construction.
But it's also not bizarre to refer it while building AST tree. I'll modify the implementation accordingly.
- Additionally refactored visitTimechartCommand to reuse spanLiteral definition Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
| if (field != null) { | ||
| return StringUtils.format("span(%s, %s %s)", field, value, node.getUnit().getName()); | ||
| } else { | ||
| return StringUtils.format("span(%s %s)", value, node.getUnit().getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no test for verification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted this change to Span as span will always come with a field with latest implementation -- I inject @timestamp to spans without a field specified in the AST layer now.
…ementation Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
|
This PR is stalled because it has been open for 2 weeks with no activity. |
Hi @yuancu , is this implementation still in track? |
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
* Support refering to implicit @timestamp field in time-based aggregations Signed-off-by: Yuanchun Shen <[email protected]> * Update documentation of stats to reflect that span can be used without specifying a field Signed-off-by: Yuanchun Shen <[email protected]> * Move @timestamp reference to AST layer - Additionally refactored visitTimechartCommand to reuse spanLiteral definition Signed-off-by: Yuanchun Shen <[email protected]> * Unit test visitSpanLiteral, vistSpanClause, and visitTimechartParamter Signed-off-by: Yuanchun Shen <[email protected]> * Revert changes to Span will always have a field with the current implementation Signed-off-by: Yuanchun Shen <[email protected]> * Throw exception for zero span Signed-off-by: Yuanchun Shen <[email protected]> --------- Signed-off-by: Yuanchun Shen <[email protected]> (cherry picked from commit c30d5d0) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…n span (#4610) * Support refering to implicit `@timestamp` field in span (#4138) * Support refering to implicit @timestamp field in time-based aggregations Signed-off-by: Yuanchun Shen <[email protected]> * Update documentation of stats to reflect that span can be used without specifying a field Signed-off-by: Yuanchun Shen <[email protected]> * Move @timestamp reference to AST layer - Additionally refactored visitTimechartCommand to reuse spanLiteral definition Signed-off-by: Yuanchun Shen <[email protected]> * Unit test visitSpanLiteral, vistSpanClause, and visitTimechartParamter Signed-off-by: Yuanchun Shen <[email protected]> * Revert changes to Span will always have a field with the current implementation Signed-off-by: Yuanchun Shen <[email protected]> * Throw exception for zero span Signed-off-by: Yuanchun Shen <[email protected]> --------- Signed-off-by: Yuanchun Shen <[email protected]> (cherry picked from commit c30d5d0) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Change pattern variable to cast Signed-off-by: Yuanchun Shen <[email protected]> --------- Signed-off-by: Yuanchun Shen <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Yuanchun Shen <[email protected]>
Description
This PR allows makes the query
source=my-index | stats count() by span(1h)equivalent tosource=my-index | stats count() by span(@timestamp, 1h)by span(1d)asby span(@timestamp, 1d)Related Issues
Resolves #4136, resolves #4527
Check List
--signoffor-s.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.