phet commented on a change in pull request #3414:
URL: https://github.com/apache/gobblin/pull/3414#discussion_r734266371



##########
File path: 
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/FlowSpecSearchObject.java
##########
@@ -51,4 +61,127 @@
   public static FlowSpecSearchObject fromFlowId(FlowId flowId) {
     return 
FlowSpecSearchObject.builder().flowGroup(flowId.getFlowGroup()).flowName(flowId.getFlowName()).build();
   }
+
+  /** This expects at least one parameter of `this` to be not null */
+  @Override
+  public String augmentBaseGetStatement(String baseStatement)
+      throws IOException {
+    List<String> conditions = new ArrayList<>();
+
+    if (this.getFlowSpecUri() != null) {
+      conditions.add("spec_uri = ?");
+    }
+
+    if (this.getFlowGroup() != null) {
+      conditions.add("flow_group = ?");
+    }
+
+    if (this.getFlowName() != null) {
+      conditions.add("flow_name = ?");
+    }
+
+    if (this.getTemplateURI() != null) {
+      conditions.add("template_uri = ?");
+    }
+
+    if (this.getUserToProxy() != null) {
+      conditions.add("user_to_proxy = ?");
+    }
+
+    if (this.getSourceIdentifier() != null) {
+      conditions.add("source_identifier = ?");
+    }
+
+    if (this.getDestinationIdentifier() != null) {
+      conditions.add("destination_identifier = ?");
+    }
+
+    if (this.getSchedule() != null) {
+      conditions.add("schedule = ?");
+    }
+
+    if (this.getModifiedTimestamp() != null) {
+      conditions.add("modified_time = ?");
+    }
+
+    if (this.getIsRunImmediately() != null) {
+      conditions.add("isRunImmediately = ?");
+    }
+
+    if (this.getOwningGroup() != null) {
+      conditions.add("owning_group = ?");
+    }
+
+    // If the propertyFilter is myKey=myValue, it looks for a config where key 
is `myKey` and value contains string `myValue`.
+    // If the propertyFilter string does not have `=`, it considers the string 
as a key and just looks for its existence.
+    // Multiple occurrences of `=` in  propertyFilter are not supported and 
ignored completely.
+    if (this.getPropertyFilter() != null) {
+      String propertyFilter = this.getPropertyFilter();
+      Splitter commaSplitter = 
Splitter.on(",").trimResults().omitEmptyStrings();
+      for (String property : commaSplitter.splitToList(propertyFilter)) {
+        if (property.contains("=")) {
+          String[] keyValue = property.split("=");
+          if (keyValue.length != 2) {
+            log.error("Incorrect flow config search query");
+            continue;
+          }
+          conditions.add("spec_json->'$.configAsProperties.\"" + keyValue[0] + 
"\"' like " + "'%" + keyValue[1] + "%'");
+        } else {
+          conditions.add("spec_json->'$.configAsProperties.\"" + property + 
"\"' is not null");
+        }
+      }
+    }
+
+    if (conditions.size() == 0) {
+      throw new IOException("At least one condition is required to query flow 
configs.");
+    }
+
+    return baseStatement + String.join(" AND ", conditions);
+  }
+
+  @Override
+  public void completePreparedStatement(PreparedStatement statement)
+      throws SQLException {
+    int i = 0;
+
+    if (this.getFlowSpecUri() != null) {

Review comment:
       I actually just copied and moved these existing impls from (the 
pre-edit) `MysqlSpecStore`, but I see the point you raised.  I don't want to go 
too far on building an abstraction, since it's orthogonal to the core aim here, 
but I will add a 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: [email protected]

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


Reply via email to