Fix vertica metric name list with dimensions
Monasca tempest test list_metrics_names_with_dimensions was failing on both vertica 7.2.1 and vertica 8.0.0 because in the java api code it doesn't have the metric dimension part join into the query. Change-Id: Ifd9be561acd275a3019075af96f94d1ebea57b86 Closes-Bug: #1657512
This commit is contained in:
parent
c1ab9792f6
commit
fe13824c7e
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) Copyright 2014, 2016 Hewlett Packard Enterprise Development LP
|
||||
* (C) Copyright 2014, 2016, 2017 Hewlett Packard Enterprise Development LP
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
|
@ -57,12 +57,14 @@ public class MetricDefinitionVerticaRepoImpl implements MetricDefinitionRepo {
|
|||
+ "%s "; // limit goes here
|
||||
|
||||
private static final String FIND_METRIC_NAMES_SQL =
|
||||
"SELECT distinct def.name "
|
||||
"SELECT %s distinct def.name "
|
||||
+ "FROM MonMetrics.Definitions def "
|
||||
+ "JOIN MonMetrics.DefinitionDimensions defDimsSub ON def.id = defDimsSub.definition_id "
|
||||
+ "WHERE def.tenant_id = :tenantId " // tenantId
|
||||
+ "%s " // optional offset goes here
|
||||
+ "%s " // Offset goes here
|
||||
+ "%s " // Dimensions and clause goes here
|
||||
+ "ORDER BY def.name ASC %s "; // Limit goes here.
|
||||
+ "ORDER BY def.name ASC "
|
||||
+ "%s "; // Limit goes here.
|
||||
|
||||
private static final String TABLE_TO_JOIN_ON = "defDimsSub";
|
||||
|
||||
|
@ -119,9 +121,13 @@ public class MetricDefinitionVerticaRepoImpl implements MetricDefinitionRepo {
|
|||
// Can't bind limit in a nested sub query. So, just tack on as String.
|
||||
String limitPart = " limit " + Integer.toString(limit + 1);
|
||||
|
||||
String sql = String.format(FIND_METRIC_NAMES_SQL, this.dbHint, offsetPart, limitPart);
|
||||
|
||||
try (Handle h = db.open()) {
|
||||
String sql = String.format(
|
||||
FIND_METRIC_NAMES_SQL,
|
||||
this.dbHint,
|
||||
offsetPart,
|
||||
MetricQueries.buildDimensionAndClause(dimensions, TABLE_TO_JOIN_ON),
|
||||
limitPart);
|
||||
|
||||
Query<Map<String, Object>> query = h.createQuery(sql).bind("tenantId", tenantId);
|
||||
|
||||
|
|
Loading…
Reference in New Issue