-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
InfluxDB: Add support for >=
and <=
comparison operators to IQL Query Builder
#77917
InfluxDB: Add support for >=
and <=
comparison operators to IQL Query Builder
#77917
Conversation
…xQL Query Builder
@itsmylife this should be ready for review |
Actually, this needs a front-end change too - I'll make that shortly |
This ensures that the query translates correctly between raw and builder mode
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 looks good. Thanks a lot. Would you mind adding some unit tests for this?
Whoops, yes - added |
This preserves the pre-existing behaviour, fixing a failing test
There is a unit test failing in
|
@@ -163,7 +163,7 @@ export default class InfluxQueryModel { | |||
if (interpolate) { | |||
value = this.templateSrv.replace(value, this.scopedVars); | |||
} | |||
if (!operator.startsWith('>') && !operator.startsWith('<') && operator != '<>') { | |||
if ((!operator.startsWith('>') && !operator.startsWith('<')) || operator === '<>') { |
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.
👍
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.
Yep - I'd inverted the check
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.
LGTM!
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.
Code looks good but I'm seeing a bug with the inclusivity of the comparison operators. I currently have the influxdbBackendMigration
feature flag enabled
It looks as though the <
and >
operators are inclusive, but not entirely?
Also it looks as though the <=
and >=
operators aren't entirely inclusive? I would expect 2 >= 2 <= 2 === true
@ismail Something we might want to address (in another issue/PR), would be to smooth out the UI in the query builder with custom input.
.
When you're searching against a numeric field we should have better support for custom input, instead of always seeing the "No options found" even if you'd already inserted a custom input.
Another nit that should be addressed in another issue is always getting <>
as the first suggestion when you type <
or >
is annoying. It should be at the bottom, or not included in the dropdown as a suggestion as we already have !=
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.
Actually nevermind! This is already a "problem" on main, so I'm actually fine with merging this in as is. This is a problem with floats, and the rounding of them in the viz. If I compare against the actual values returned by influx, and not what is visualized, this works as expected!
@gtk-grafana in your second condition you're comparing against a different field ( |
@btasker no that was a mistake, and I had also left an aggregation in my query which was giving me slighly different values each query 🤦 . After checking against values that aren't changing each query, it works as expected. |
@gtk-grafana You want @itsmylife ;) |
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.
🚀
What is this feature?
Adds support to the InfluxQL Query Editor for the
>=
and<=
comparison operatorsWhy do we need this feature?
To simplify queries against numeric fields
Who is this feature for?
InfluxQL Query Builder users who wish to include WHERE conditions using greater/less than or equal to
Which issue(s) does this PR fix?:
Fixes #77916
Special notes for your reviewer:
Please check that: