jihaozh commented on a change in pull request #3724: [TE] Migration endpoints 
for anomaly function and application
URL: https://github.com/apache/incubator-pinot/pull/3724#discussion_r249910381
 
 

 ##########
 File path: 
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlDetectionAlertConfigTranslator.java
 ##########
 @@ -192,8 +195,17 @@ public DetectionAlertConfigDTO 
translate(Map<String,Object> yamlAlertConfig) {
     List<String> detectionNames = 
ConfigUtils.getList(yamlAlertConfig.get(PROP_DETECTION_NAMES));
 
     try {
-      detectionConfigIds.addAll(detectionNames.stream().map(detectionName ->  
this.detectionConfigDAO.findByPredicate(
-          Predicate.EQ("name", 
detectionName)).get(0).getId()).collect(Collectors.toList()));
+      detectionConfigIds.addAll(detectionNames.stream().map(detectionName -> {
+        List<DetectionConfigDTO> detectionConfigDTOs = 
DAORegistry.getInstance().getDetectionConfigManager()
+            .findByPredicate(Predicate.EQ("name", detectionName));
+
+        if (!detectionConfigDTOs.isEmpty()) {
+          return detectionConfigDTOs.get(0).getId();
+        } else {
+          return DAORegistry.getInstance().getAnomalyFunctionDAO()
 
 Review comment:
   Is it possible that we don't access the anomaly function DAO here? This 
translator will be kept after the migration, i.e. after the anomaly function 
DAO deprecated. I'd prefer not to refer it in the new code.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to