-
Notifications
You must be signed in to change notification settings - Fork 924
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
feat(vis_type_vega): support reading time field #9152
base: main
Are you sure you want to change the base?
feat(vis_type_vega): support reading time field #9152
Conversation
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Signed-off-by: Yulong Ruan <[email protected]>
39872e3
to
a4be69c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9152 +/- ##
==========================================
+ Coverage 60.94% 61.03% +0.09%
==========================================
Files 3809 3813 +4
Lines 91270 91412 +142
Branches 14414 14442 +28
==========================================
+ Hits 55620 55797 +177
+ Misses 32096 32055 -41
- Partials 3554 3560 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -34,6 +55,11 @@ export class PPLQueryParser { | |||
); | |||
} | |||
|
|||
if (timefield) { | |||
const query = this.injectTimeFilter(url.body.query, timefield); | |||
url.body.query = query; |
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.
Is this the url that vega uses to query the cluster? I wouldn't expect the url parser to format/mutate the url, but I'm new to this area so it may be a gap in my understanding.
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.
Is this the url that vega uses to query the cluster?
Yes, url.body.query
is the ppl query and will be send to opensearch. We modify it here to encapsulate the time filter from the UI, for example, the time range user selected on a dashboard. The behavior is the same as vega visualization with opensearch DSL which modified the query DSL to add time filter.
I wouldn't expect the url parser to format/mutate the url
Could you please share your concern?
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.
That makes sense. No concerns, my expectation was that the parser is a pure function but it looks like this is more of a parser and formatter of the original url if I'm understanding correctly.
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 got your point now, I think we can also make it a pure function, for example we can deep copy the url
object and then modify the deep copied object. I don’t notice much of a difference in this particular case since the existing parser mutate the url object as well, but I’d love to hear your thoughts on it :)
Signed-off-by: Yulong Ruan <[email protected]>
const timefield = url[TIMEFIELD]; | ||
delete url[TIMEFIELD]; |
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 this synced to other apps(discovery/dashboards)?
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.
This is not the current browser url, it's the url
property of vega-lite config object, the TIMEFIELD defines the time field name of current index, for example, timestamp
, and it will used as the time filter of the query.
Description
This PR introduces time range filter support to Vega visualizations with PPL queries. When
"%timefield%"
is specified, the time range filter from the dashboard will be applied to the PPL query automatically.Before This PR
Vega visualizations with PPL queries did not respect the time range set on the dashboard. Regardless of the selected time range, the query remained unaffected.
After This PR
With the addition of
"%timefield%"
, changing the time range filter on a dashboard now impacts Vega visualizations with PPL queries.Example
{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": { "url": { + "%timefield%": "timestamp", "%type%": "ppl", "body": { "query": "source=opensearch_dashboards_sample_data_logs | stats count() as request_count by extension | sort -request_count" } } } }
Issues Resolved
#9169
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration