Skip to content

Commit

Permalink
Add missing API method in prometheus table
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <[email protected]>
  • Loading branch information
dai-chen committed Oct 21, 2022
1 parent c137ac3 commit 3a9d217
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ public PrometheusMetricTable(PrometheusClient prometheusService,
this.prometheusQueryRequest = Optional.of(prometheusQueryRequest);
}

@Override
public boolean exists() {
throw new UnsupportedOperationException(
"Prometheus metric exists operation is not supported");
}

@Override
public void create(Map<String, ExprType> schema) {
throw new UnsupportedOperationException(
"Prometheus metric create operation is not supported");
}

@Override
public Map<String, ExprType> getFieldTypes() {
if (cachedFieldTypes == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
Expand All @@ -19,6 +20,7 @@
import static org.opensearch.sql.prometheus.data.constants.PrometheusFieldConstants.VALUE;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -125,4 +127,14 @@ void testOptimize() {
assertEquals(inputPlan, optimizedPlan);
}

@Test
void testUnsupportedOperation() {
PrometheusQueryRequest prometheusQueryRequest = new PrometheusQueryRequest();
PrometheusMetricTable prometheusMetricTable =
new PrometheusMetricTable(client, prometheusQueryRequest);

assertThrows(UnsupportedOperationException.class, prometheusMetricTable::exists);
assertThrows(UnsupportedOperationException.class,
() -> prometheusMetricTable.create(Collections.emptyMap()));
}
}

0 comments on commit 3a9d217

Please sign in to comment.