You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "shauryachats (via GitHub)" <gi...@apache.org> on 2025/08/06 23:26:15 UTC

[PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

shauryachats opened a new pull request, #16531:
URL: https://github.com/apache/pinot/pull/16531

   (no comment)


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

Posted by "shauryachats (via GitHub)" <gi...@apache.org>.
shauryachats commented on code in PR #16531:
URL: https://github.com/apache/pinot/pull/16531#discussion_r2268235561


##########
pinot-common/src/main/java/org/apache/pinot/common/response/PinotBrokerTimeSeriesResponse.java:
##########
@@ -108,6 +112,55 @@ public static PinotBrokerTimeSeriesResponse fromTimeSeriesBlock(TimeSeriesBlock
     return convertBucketedSeriesBlock(seriesBlock);
   }
 
+  public BrokerResponse toBrokerResponse() {
+    DataSchema dataSchema = deriveBrokerResponseDataSchema(_data);
+    ResultTable resultTable = new ResultTable(dataSchema, deriveBrokerResponseRows(_data, dataSchema.getColumnNames()));
+    BrokerResponseNativeV2 brokerResponse = new BrokerResponseNativeV2();
+    brokerResponse.setResultTable(resultTable);
+    return brokerResponse;
+  }
+
+  private List<Object[]> deriveBrokerResponseRows(Data data, String[] columnNames) {

Review Comment:
   I would prefer to do that in a subsequent PR because currently the `submitAndGet` method in [QueryDispatcher](https://github.com/apache/pinot/blob/master/pinot-query-runtime/src/main/java/org/apache/pinot/query/service/dispatch/QueryDispatcher.java#L731) returns a `PinotBrokerTimeSeriesResponse` through multiple layers (`TimeSeriesResponseHandler`, `PinotClientRequest`, `BrokerRequestHandlerDelegate`, etc), which would add on to the impact of this PR. 
   
   Furthermore, we would still need to convert `BrokerResponse` back to `PinotBrokerTimeSeriesResponse` since the current `GET /timeseries/api/v1/query_range` expects a Prometheus-compatible response. 



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

Posted by "shauryachats (via GitHub)" <gi...@apache.org>.
shauryachats commented on PR #16531:
URL: https://github.com/apache/pinot/pull/16531#issuecomment-3162074325

   The failing integration test is 
   ```
   2025-08-06T21:56:44.1284639Z [ERROR] org.apache.pinot.integration.tests.OfflineClusterMemBasedServerQueryKillingTest.testDigestOOM2MSE -- Time elapsed: 5.415 s <<< FAILURE!
   ```
   introduced yesterday by @vrajat: https://github.com/apache/pinot/pull/16514.
   Also failing for other PRs: https://github.com/apache/pinot/pull/16526, https://github.com/apache/pinot/pull/16515


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

Posted by "shauryachats (via GitHub)" <gi...@apache.org>.
shauryachats commented on code in PR #16531:
URL: https://github.com/apache/pinot/pull/16531#discussion_r2271439122


##########
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java:
##########
@@ -280,6 +280,40 @@ public void processSqlWithMultiStageQueryEnginePost(String query, @Suspended Asy
     }
   }
 
+  @POST
+  @ManagedAsync
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("query/timeseries")
+  @ApiOperation(value = "Query Pinot using the Time Series Engine")
+  @ManualAuthorization
+  public void processTimeSeriesQueryEngine(String query, @Suspended AsyncResponse asyncResponse,
+      @Context org.glassfish.grizzly.http.server.Request requestCtx, @Context HttpHeaders httpHeaders) {
+    try {
+      JsonNode requestJson = JsonUtils.stringToJsonNode(query);
+      if (!requestJson.has("query")) {
+        throw new IllegalStateException("Payload is missing the query string field 'sql'");
+      }
+      String language = requestJson.get(Request.LANGUAGE).asText();
+      String queryString = requestJson.get("query").asText();
+      try (RequestScope requestContext = Tracing.getTracer().createRequestScope()) {
+        PinotBrokerTimeSeriesResponse response = executeTimeSeriesQuery(language, queryString,
+            JsonUtils.jsonNodeToStringMap(requestJson), requestContext,
+          makeHttpIdentity(requestCtx), httpHeaders);
+        if (response.getErrorType() != null && !response.getErrorType().isEmpty()) {

Review Comment:
   Moved this logic to `toBrokerResponse` to return a `BrokerResponse` for error payloads.
   Added a TODO to make proper error-code driven exceptions for timeseries.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

Posted by "ankitsultana (via GitHub)" <gi...@apache.org>.
ankitsultana commented on code in PR #16531:
URL: https://github.com/apache/pinot/pull/16531#discussion_r2261898748


##########
pinot-common/src/main/java/org/apache/pinot/common/response/PinotBrokerTimeSeriesResponse.java:
##########
@@ -108,6 +112,55 @@ public static PinotBrokerTimeSeriesResponse fromTimeSeriesBlock(TimeSeriesBlock
     return convertBucketedSeriesBlock(seriesBlock);
   }
 
+  public BrokerResponse toBrokerResponse() {
+    DataSchema dataSchema = deriveBrokerResponseDataSchema(_data);
+    ResultTable resultTable = new ResultTable(dataSchema, deriveBrokerResponseRows(_data, dataSchema.getColumnNames()));
+    BrokerResponseNativeV2 brokerResponse = new BrokerResponseNativeV2();
+    brokerResponse.setResultTable(resultTable);
+    return brokerResponse;
+  }
+
+  private List<Object[]> deriveBrokerResponseRows(Data data, String[] columnNames) {

Review Comment:
   Hmm this is converting `Data` to Broker Response. Data in turn was generated from a Time Series Block.
   
   Can you directly generate broker response from a Time Series Block?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

Posted by "vrajat (via GitHub)" <gi...@apache.org>.
vrajat commented on PR #16531:
URL: https://github.com/apache/pinot/pull/16531#issuecomment-3162406923

   Fix in https://github.com/apache/pinot/pull/16533


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

Posted by "shauryachats (via GitHub)" <gi...@apache.org>.
shauryachats commented on code in PR #16531:
URL: https://github.com/apache/pinot/pull/16531#discussion_r2268245919


##########
pinot-common/src/main/java/org/apache/pinot/common/response/PinotBrokerTimeSeriesResponse.java:
##########
@@ -108,6 +112,55 @@ public static PinotBrokerTimeSeriesResponse fromTimeSeriesBlock(TimeSeriesBlock
     return convertBucketedSeriesBlock(seriesBlock);
   }
 
+  public BrokerResponse toBrokerResponse() {
+    DataSchema dataSchema = deriveBrokerResponseDataSchema(_data);
+    ResultTable resultTable = new ResultTable(dataSchema, deriveBrokerResponseRows(_data, dataSchema.getColumnNames()));
+    BrokerResponseNativeV2 brokerResponse = new BrokerResponseNativeV2();
+    brokerResponse.setResultTable(resultTable);
+    return brokerResponse;
+  }
+
+  private List<Object[]> deriveBrokerResponseRows(Data data, String[] columnNames) {

Review Comment:
   Another option is bubbling up the `TimeSeriesBlock` directly to the `PinotClientRequest` and transforming it to `PinotBrokerTimeSeriesResponse` and `BrokerResponse` based on the respective timeseries API.
   
   Any other solution apart from this would result in an additional transformation from `PinotBrokerTimeSeriesResponse` to `BrokerResponse` or vice versa which might add unnecessary latency for bigger payloads.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #16531:
URL: https://github.com/apache/pinot/pull/16531#issuecomment-3161994347

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/16531?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `0%` with `34 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 56.35%. Comparing base ([`1d03cd8`](https://app.codecov.io/gh/apache/pinot/commit/1d03cd89e548dadbba7b7e0a674408eebe4b1112?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`6e681fe`](https://app.codecov.io/gh/apache/pinot/commit/6e681fed21078d4eb00d4d5fcd1fbdaf6b1e84b7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 15 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/pinot/pull/16531?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...common/response/PinotBrokerTimeSeriesResponse.java](https://app.codecov.io/gh/apache/pinot/pull/16531?src=pr&el=tree&filepath=pinot-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fcommon%2Fresponse%2FPinotBrokerTimeSeriesResponse.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vcmVzcG9uc2UvUGlub3RCcm9rZXJUaW1lU2VyaWVzUmVzcG9uc2UuamF2YQ==) | 0.00% | [33 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/16531?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...ain/java/org/apache/pinot/spi/utils/JsonUtils.java](https://app.codecov.io/gh/apache/pinot/pull/16531?src=pr&el=tree&filepath=pinot-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fspi%2Futils%2FJsonUtils.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvdXRpbHMvSnNvblV0aWxzLmphdmE=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/16531?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (1d03cd8) and HEAD (6e681fe). Click for more details.
   > 
   > <details><summary>HEAD has 36 uploads less than BASE</summary>
   >
   >| Flag | BASE (1d03cd8) | HEAD (6e681fe) |
   >|------|------|------|
   >|java-21|5|1|
   >|unittests1|2|1|
   >|unittests|4|1|
   >|temurin|10|1|
   >|unittests2|2|0|
   >|java-11|5|0|
   >|integration|6|0|
   >|integration1|2|0|
   >|custom-integration1|2|0|
   >|integration2|2|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #16531      +/-   ##
   ============================================
   - Coverage     63.23%   56.35%   -6.89%     
   + Complexity     1362      699     -663     
   ============================================
     Files          3011     2356     -655     
     Lines        174271   129636   -44635     
     Branches      26685    20611    -6074     
   ============================================
   - Hits         110205    73059   -37146     
   + Misses        55656    50555    -5101     
   + Partials       8410     6022    -2388     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration1](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration2](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-11](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-21](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.35% <0.00%> (-6.85%)` | :arrow_down: |
   | [temurin](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.35% <0.00%> (-6.89%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.35% <0.00%> (-6.88%)` | :arrow_down: |
   | [unittests1](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.35% <0.00%> (-0.04%)` | :arrow_down: |
   | [unittests2](https://app.codecov.io/gh/apache/pinot/pull/16531/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/pinot/pull/16531?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

Posted by "ankitsultana (via GitHub)" <gi...@apache.org>.
ankitsultana commented on code in PR #16531:
URL: https://github.com/apache/pinot/pull/16531#discussion_r2271148005


##########
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java:
##########
@@ -280,6 +280,40 @@ public void processSqlWithMultiStageQueryEnginePost(String query, @Suspended Asy
     }
   }
 
+  @POST
+  @ManagedAsync
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("query/timeseries")
+  @ApiOperation(value = "Query Pinot using the Time Series Engine")
+  @ManualAuthorization
+  public void processTimeSeriesQueryEngine(String query, @Suspended AsyncResponse asyncResponse,
+      @Context org.glassfish.grizzly.http.server.Request requestCtx, @Context HttpHeaders httpHeaders) {
+    try {
+      JsonNode requestJson = JsonUtils.stringToJsonNode(query);
+      if (!requestJson.has("query")) {
+        throw new IllegalStateException("Payload is missing the query string field 'sql'");

Review Comment:
   wrong error message: `'sql'`



##########
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java:
##########
@@ -280,6 +280,40 @@ public void processSqlWithMultiStageQueryEnginePost(String query, @Suspended Asy
     }
   }
 
+  @POST
+  @ManagedAsync
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("query/timeseries")
+  @ApiOperation(value = "Query Pinot using the Time Series Engine")
+  @ManualAuthorization
+  public void processTimeSeriesQueryEngine(String query, @Suspended AsyncResponse asyncResponse,

Review Comment:
   rename `query` to `requestStr`?



##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/TimeSeriesRequestHandler.java:
##########
@@ -169,57 +169,41 @@ public boolean cancelQueryByClientId(String clientQueryId, int timeoutMs, Execut
     return false;
   }
 
-  private RangeTimeSeriesRequest buildRangeTimeSeriesRequest(String language, String queryParamString)
+  private RangeTimeSeriesRequest buildRangeTimeSeriesRequest(String language, String queryParamString,
+      Map<String, String> queryParams)
       throws URISyntaxException {
-    List<NameValuePair> pairs = URLEncodedUtils.parse(
-        new URI("http://localhost?" + queryParamString), "UTF-8");
-    String query = null;
-    Long startTs = null;
-    Long endTs = null;
-    String step = null;
-    String timeoutStr = null;
-    int limit = RangeTimeSeriesRequest.DEFAULT_SERIES_LIMIT;
-    int numGroupsLimit = RangeTimeSeriesRequest.DEFAULT_NUM_GROUPS_LIMIT;
-    for (NameValuePair nameValuePair : pairs) {
-      switch (nameValuePair.getName()) {
-        case "query":
-          query = nameValuePair.getValue();
-          break;
-        case "start":
-          startTs = Long.parseLong(nameValuePair.getValue());
-          break;
-        case "end":
-          endTs = Long.parseLong(nameValuePair.getValue());
-          break;
-        case "step":
-          step = nameValuePair.getValue();
-          break;
-        case "timeout":
-          timeoutStr = nameValuePair.getValue();
-          break;
-        case "limit":
-          limit = Integer.parseInt(nameValuePair.getValue());
-          break;
-        case "numGroupsLimit":
-          numGroupsLimit = Integer.parseInt(nameValuePair.getValue());
-          break;
-        default:
-          /* Okay to ignore unknown parameters since the language implementor may be using them. */
-          break;
-      }
+    Map<String, String> mergedParams = new HashMap<>(queryParams);
+    // If queryParams is empty, parse the queryParamString to extract parameters.
+    if (queryParams.isEmpty()) {
+      URLEncodedUtils.parse(new URI("http://localhost?" + queryParamString), "UTF-8")
+          .forEach(pair -> mergedParams.putIfAbsent(pair.getName(), pair.getValue()));
     }
-    Long stepSeconds = getStepSeconds(step);
+
+    String query = mergedParams.get("query");
+    Long startTs = parseLong(mergedParams.get("start"));
+    Long endTs = parseLong(mergedParams.get("end"));
+    Long stepSeconds = getStepSeconds(mergedParams.get("step"));
+    Duration timeout = StringUtils.isNotBlank(mergedParams.get("timeout"))
+        ? HumanReadableDuration.from(mergedParams.get("timeout")) : Duration.ofMillis(_brokerTimeoutMs);
+
     Preconditions.checkNotNull(query, "Query cannot be null");
     Preconditions.checkNotNull(startTs, "Start time cannot be null");
     Preconditions.checkNotNull(endTs, "End time cannot be null");
     Preconditions.checkState(stepSeconds != null && stepSeconds > 0, "Step must be a positive integer");
-    Duration timeout = Duration.ofMillis(_brokerTimeoutMs);
-    if (StringUtils.isNotBlank(timeoutStr)) {
-      timeout = HumanReadableDuration.from(timeoutStr);
-    }
-    // TODO: Pass full raw query param string to the request
-    return new RangeTimeSeriesRequest(language, query, startTs, endTs, stepSeconds, timeout, limit, numGroupsLimit,
-        queryParamString);
+
+    return new RangeTimeSeriesRequest(language, query, startTs, endTs, stepSeconds, timeout,
+        parseIntOrDefault(mergedParams.get("limit"), RangeTimeSeriesRequest.DEFAULT_SERIES_LIMIT),
+        parseIntOrDefault(mergedParams.get("numGroupsLimit"), RangeTimeSeriesRequest.DEFAULT_NUM_GROUPS_LIMIT),
+        queryParamString
+    );
+  }
+
+  private Long parseLong(String value) {

Review Comment:
   nit: rename this to `parseLongSafe` since it collides with `Long.parseLong` and may cause confusion



##########
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java:
##########
@@ -280,6 +280,40 @@ public void processSqlWithMultiStageQueryEnginePost(String query, @Suspended Asy
     }
   }
 
+  @POST
+  @ManagedAsync
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("query/timeseries")
+  @ApiOperation(value = "Query Pinot using the Time Series Engine")
+  @ManualAuthorization
+  public void processTimeSeriesQueryEngine(String query, @Suspended AsyncResponse asyncResponse,
+      @Context org.glassfish.grizzly.http.server.Request requestCtx, @Context HttpHeaders httpHeaders) {
+    try {
+      JsonNode requestJson = JsonUtils.stringToJsonNode(query);
+      if (!requestJson.has("query")) {
+        throw new IllegalStateException("Payload is missing the query string field 'sql'");
+      }
+      String language = requestJson.get(Request.LANGUAGE).asText();
+      String queryString = requestJson.get("query").asText();
+      try (RequestScope requestContext = Tracing.getTracer().createRequestScope()) {
+        PinotBrokerTimeSeriesResponse response = executeTimeSeriesQuery(language, queryString,
+            JsonUtils.jsonNodeToStringMap(requestJson), requestContext,

Review Comment:
   couldn't we do this in the beginning and then use the map for checking language, queryString, etc.?



##########
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java:
##########
@@ -280,6 +280,40 @@ public void processSqlWithMultiStageQueryEnginePost(String query, @Suspended Asy
     }
   }
 
+  @POST
+  @ManagedAsync
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("query/timeseries")
+  @ApiOperation(value = "Query Pinot using the Time Series Engine")
+  @ManualAuthorization
+  public void processTimeSeriesQueryEngine(String query, @Suspended AsyncResponse asyncResponse,
+      @Context org.glassfish.grizzly.http.server.Request requestCtx, @Context HttpHeaders httpHeaders) {
+    try {
+      JsonNode requestJson = JsonUtils.stringToJsonNode(query);
+      if (!requestJson.has("query")) {
+        throw new IllegalStateException("Payload is missing the query string field 'sql'");
+      }
+      String language = requestJson.get(Request.LANGUAGE).asText();
+      String queryString = requestJson.get("query").asText();
+      try (RequestScope requestContext = Tracing.getTracer().createRequestScope()) {
+        PinotBrokerTimeSeriesResponse response = executeTimeSeriesQuery(language, queryString,
+            JsonUtils.jsonNodeToStringMap(requestJson), requestContext,
+          makeHttpIdentity(requestCtx), httpHeaders);
+        if (response.getErrorType() != null && !response.getErrorType().isEmpty()) {

Review Comment:
   We should convert this to broker response too. Broker has a well-defined way for returning exceptions



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [timeseries] Introducing POST /query/timeseries as a BrokerResponse compatible timeseries API [pinot]

Posted by "ankitsultana (via GitHub)" <gi...@apache.org>.
ankitsultana merged PR #16531:
URL: https://github.com/apache/pinot/pull/16531


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org