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

misc(query):make metric name in labelnames API optional #1685

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,29 @@ class MultiPartitionPlannerSpec extends AnyFunSpec with Matchers with PlanValida
.children(0).asInstanceOf[LabelNamesExec].endMs shouldEqual (endSeconds * 1000)
}

it("should materialize LabelNames query without metric filter correctly") {
val (startSeconds: Int, endSeconds: Int, engine: MultiPartitionPlanner) = getPlannerForMetadataQueryTests

val promQl = """{job="app"}"""
val lv = Parser.labelNamesQueryToLogicalPlan(promQl, TimeStepParams(startSeconds, step, endSeconds))

val promQlQueryParams = PromQlQueryParams(promQl, startSeconds, step, endSeconds, Some("/api/v2/labels/name"))
val execPlan = engine.materialize(lv, QueryContext(origQueryParams = promQlQueryParams, plannerParams =
PlannerParams(processMultiPartition = true)))

execPlan.isInstanceOf[LabelNamesDistConcatExec] shouldEqual true
execPlan.children.size shouldEqual 2

val expectedUrlParams = Map("match[]" -> promQl)
execPlan.children(1).asInstanceOf[MetadataRemoteExec].urlParams shouldEqual (expectedUrlParams)
execPlan.children(1).asInstanceOf[MetadataRemoteExec].queryContext.origQueryParams.asInstanceOf[PromQlQueryParams].
endSecs shouldEqual (localPartitionStart - 1)
execPlan.children(0).asInstanceOf[LabelNamesDistConcatExec]
.children(0).asInstanceOf[LabelNamesExec].startMs shouldEqual (localPartitionStart * 1000)
execPlan.children(0).asInstanceOf[LabelNamesDistConcatExec]
.children(0).asInstanceOf[LabelNamesExec].endMs shouldEqual (endSeconds * 1000)
}

it ("should generate correct plan for multipartition BinaryJoin with instant function") {
def partitions(timeRange: TimeRange): List[PartitionAssignment] = List(PartitionAssignment("remote", "remote-url",
TimeRange(timeRange.startMs, timeRange.endMs)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ case class InstantExpression(metricName: Option[String],
}

def toLabelNamesPlan(timeParams: TimeRangeParams): LabelNames = {
val columnFilters = getUnvalidatedColumnFilters()
LabelNames(columnFilters, timeParams.start * 1000, timeParams.end * 1000)
}

Expand Down
Loading