jasonyanwenl commented on a change in pull request #5866:
URL: https://github.com/apache/incubator-pinot/pull/5866#discussion_r473093021



##########
File path: 
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/api/detection/AnomalyDetectionResource.java
##########
@@ -464,6 +420,38 @@ TaskDTO generateTaskConfig(DetectionConfigDTO 
detectionConfigDTO,
     return taskDTO;
   }
 
+  long saveOnlineDetectionData(JsonNode payloadNode,
+      DatasetConfigDTO datasetConfigDTO, MetricConfigDTO metricConfigDTO)
+        throws JsonProcessingException {
+    JsonNode dataNode = payloadNode.get(DATA_FIELD);
+    String timeColumnName = datasetConfigDTO.getTimeColumn();
+    String datasetName = datasetConfigDTO.getDataset();
+    String metricName = metricConfigDTO.getName();
+
+    // Check if time & metric columns exist in adhoc data
+    ArrayNode columnsNode = dataNode.withArray(COLUMNS_FIELD);
+    int[] colIndices = findTimeAndMetricColumns(columnsNode,
+        timeColumnName, metricName);
+    int timeColIdx = colIndices[0];
+    int metricColIdx = colIndices[1];
+    Preconditions.checkArgument(metricColIdx>=0 && timeColIdx>=0,
+        String.format("metric: %s or time: %s not found in adhoc data.",
+            metricName, timeColumnName));
+
+    // Save online data
+    OnlineDetectionDataDTO onlineDetectionDataDTO = new 
OnlineDetectionDataDTO();
+    onlineDetectionDataDTO.setDataset(datasetName);
+    onlineDetectionDataDTO.setMetric(metricName);
+    
onlineDetectionDataDTO.setOnlineDetectionData(this.objectMapper.writeValueAsString(dataNode));

Review comment:
       Thanks! I have already limited the size of request data. But originally 
I found the column type is `MEDIUMTEXT` in our internal database. So I just 
limit the size to be 10MB. However, here in our open-source SQL script, it is 
`TEXT` so the maximum size is 64 KB like what you said. Anyway, I will keep 
consistent with our open-source version and limit the request data size to be 
less than 64KB.




----------------------------------------------------------------
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.

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



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

Reply via email to