Skip to content
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

MQE: Add support for label_join #10587

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jhesketh
Copy link
Contributor

@jhesketh jhesketh commented Feb 5, 2025

What this PR does

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@jhesketh jhesketh requested a review from a team as a code owner February 5, 2025 12:02
@jhesketh jhesketh mentioned this pull request Feb 5, 2025
Copy link
Contributor

@charleskorn charleskorn left a comment

Choose a reason for hiding this comment

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

Overall LGTM.

Could you please enable the existing label_join benchmark in pkg/streamingpromql/benchmarks/benchmarks.go and post the comparison between MQE and Prometheus' engine?

@@ -17,6 +18,43 @@ import (
"github.com/grafana/mimir/pkg/streamingpromql/types"
)

func LabelJoinFactory(dstLabelOp, separatorOp types.StringOperator, srcLabelOp []types.StringOperator) SeriesMetadataFunction {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit]

Suggested change
func LabelJoinFactory(dstLabelOp, separatorOp types.StringOperator, srcLabelOp []types.StringOperator) SeriesMetadataFunction {
func LabelJoinFactory(dstLabelOp, separatorOp types.StringOperator, srcLabelOps []types.StringOperator) SeriesMetadataFunction {

@@ -173,6 +173,53 @@ func scalarToInstantVectorOperatorFactory(args []types.Operator, _ *limiting.Mem
return scalars.NewScalarToInstantVector(inner, expressionPosition), nil
}

func LabelJoinFunctionOperatorFactory(args []types.Operator, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, _ *annotations.Annotations, expressionPosition posrange.PositionRange, timeRange types.QueryTimeRange) (types.InstantVectorOperator, error) {
if len(args) < 3 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth adding a note here that it's valid to have no source label names.

}

lb.Reset(seriesMetadata[i].Labels)
lb.Set(dst, strings.Join(labelValues, separator))
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be interesting to see if using the same strings.Builder here for every series would be more efficient - strings.Join uses a new strings.Builder under the covers for each call, so reusing the same one ourselves should allow us to avoid allocating a new buffer for every series.

Comment on lines +16 to +17
# Prometheus fails this with enableDelayedNameRemoval disabled
# Can be tested against both once https://github.com/prometheus/prometheus/pull/15975 is merged
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this has been merged - would you be able to vendor the fix into Mimir so we don't need to come back and move this later?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants