-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Pushdown Prometheus Predicates #8742 #25957
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
base: master
Are you sure you want to change the base?
Conversation
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
01a2274
to
62d8bd7
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
62d8bd7
to
dc6eaf4
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/expression/RewriteIn.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/LoggedRequest.java
Outdated
Show resolved
Hide resolved
dc6eaf4
to
b2a6f1f
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
I have the CLA signed and sent like 6 hours ago, not sure how long it usually takes to propagate to the related failing CI job. |
b2a6f1f
to
6028e80
Compare
@ebyhr could you please review & merge? I see you made recent changes to Prometheus Connector as well. |
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.
Just skimmed.
...in/trino-prometheus/src/main/java/io/trino/plugin/prometheus/expression/RewriteEqAndNeq.java
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/expression/RewriteHelpers.java
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/expression/RewriteHelpers.java
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusTableHandle.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusTableHandle.java
Outdated
Show resolved
Hide resolved
assertThat(request.extractPromQL()).isEqualTo("up{job=\"prometheus\"}[1d]"); | ||
}); | ||
|
||
assertThat(results).hasSizeBetween(1, 2); |
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.
Why is the result size non-deterministic? Please leave a code 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.
Prometheus reports the up
metric every 15 seconds, so we expect at least one row, but at most two rows if we filter for the last 15 seconds (edge case). Thanks for asking, I have added a code comment.
plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusIntegration.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusTableHandle.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusIntegration.java
Show resolved
Hide resolved
plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/PrometheusServer.java
Outdated
Show resolved
Hide resolved
private static final int PROMETHEUS_PORT = 9090; | ||
private static final String DEFAULT_VERSION = "v2.15.1"; |
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.
Does this changes required?
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.
Your question is ambiguous, what change exactly?
If you mean the change of scope from private to public, then yes, we're using this constant in the TestPrometheusIntegration
class.
If you mean the change of name from DEFAULT_VERSION
to DEFAULT_PROMETHEUS_VERSION
, then it's required to avoid ambiguity of what container exactly belongs this version to (prometheus vs. nginx).
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/expression/RewriteHelpers.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/expression/RewriteHelpers.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/expression/RewriteHelpers.java
Show resolved
Hide resolved
a666bd4
to
6c3d0bc
Compare
plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/RequestsRecorder.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/RequestsRecorder.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusTableHandle.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusSplitManager.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusSplitManager.java
Outdated
Show resolved
Hide resolved
PrometheusTableHandle tableHandle = ((PrometheusTableHandle) handle) | ||
.withPredicate(constraint.getSummary()); | ||
.withPredicate(constraint.getSummary()) | ||
.withExpressions(rewriter.rewrite(session, expression, constraint.getAssignments()).orElseGet(ImmutableList::of)); | ||
return Optional.of(new ConstraintApplicationResult<>(tableHandle, constraint.getSummary(), constraint.getExpression(), false)); |
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.
After updating tableHandle
, it looks like remainingFilter
and remainingExpression
still reference the previous state. Is that intentional?
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.
Yes, this is intentional because we can't push-down arbitrary operation for the labels map (see the testLabelLikeAndEqAndNeqNegatedPushDown
test to see why - though it's just a single edge-case example).
Yes, Trino will potentially filter something that was already pushed down, but the real value of this PR is that Prometheus doesn't have to return all the timeseries anymore and Trino doesn't have to filter them all. From now, Prometheus will always perform very efficient timeseries filtering based on provided label selectors and Trino will go just through a fraction of data compared to previous version.
In the future, someone might add support for the OR operator, or NOT(x AND y) by spitting the query into multiple Prometheus requests, potentially covering all the logical edge-cases for label filter pushdown. At that point, I think we could safely remove all the filters on label values in the above discussed lines, but I'd argue it's out-of-scope for this PR, as this itself is a major improvement already.
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/expression/RewriteHelpers.java
Outdated
Show resolved
Hide resolved
plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/expression/RewriteIn.java
Show resolved
Hide resolved
6c3d0bc
to
3b8a38d
Compare
Description
Implements pushdown for Prometheus predicates, as requested in #8742.
Additional context and related issues
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text: