raghavyadav01 commented on code in PR #20336:
URL: https://github.com/apache/pinot/pull/20336#discussion_r4649604446


##########
pinot-common/src/test/java/org/apache/pinot/common/response/PinotBrokerTimeSeriesResponseTest.java:
##########
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.common.response;
+
+import java.time.Duration;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.tsdb.spi.TimeBuckets;
+import org.apache.pinot.tsdb.spi.series.TimeSeries;
+import org.apache.pinot.tsdb.spi.series.TimeSeriesBlock;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+/// Tests the Prometheus range response rendered by the broker.
+public class PinotBrokerTimeSeriesResponseTest {
+  @Test
+  public void testMatrixOmitsMissingSamples()

Review Comment:
   Could we add a case where every series is empty and the block renders 
`result: []`? This test always has one dense series, so the all-empty path 
isn't covered.



##########
pinot-common/src/main/java/org/apache/pinot/common/response/PinotBrokerTimeSeriesResponse.java:
##########
@@ -134,11 +135,16 @@ private static PinotBrokerTimeSeriesResponse 
convertBucketedSeriesBlock(TimeSeri
       metricMap.putAll(anySeries.getTagKeyValuesAsMap());
       for (TimeSeries timeSeries : listOfTimeSeries) {
         Object[][] values = new Object[timeValues.length][];
+        int numSamples = 0;
         for (int i = 0; i < timeValues.length; i++) {
-          Object nullableValue = timeSeries.getDoubleValues()[i];
-          values[i] = new Object[]{timeValues[i], nullableValue == null ? null 
: nullableValue.toString()};
+          Double sample = timeSeries.getDoubleValues()[i];
+          if (sample != null) {
+            values[numSamples++] = new Object[]{timeValues[i], 
sample.toString()};
+          }
+        }
+        if (numSamples > 0) {

Review Comment:
   This changes what the range API returns: a missing sample is now left out 
instead of rendered as `[ts, null]`, and an all-empty series disappears. That 
is the right Prometheus behavior, but it is user-visible. Worth a release-note 
or behavior-change label, since the PR has no labels.



##########
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java:
##########
@@ -1029,6 +1029,13 @@ private QueryFingerprint 
generateQueryFingerprint(ObjectNode sqlRequestJson) thr
     return fingerprint;
   }
 
+  private static Response timeSeriesErrorResponse(QueryException e, Object 
entity) {

Review Comment:
   Only ACCESS_DENIED gets a non-200 status here. Timeouts 
(SERVER_NOT_RESPONDING) and other query errors still return 200 with 
status=error, while Prometheus clients usually expect a 4xx/5xx for them (for 
example 503 for a timeout). Is leaving those out intentional for this PR? A 
follow-up could map the rest.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to