in gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/FlowSpecSearchObject.java [69:154]
public String augmentBaseGetStatement(String baseStatement)
throws IOException {
List<String> conditions = new ArrayList<>();
List<String> limitAndOffset = new ArrayList<>();
/*
* IMPORTANT: the order of `conditions` added must align with the order of parameter binding later in `completePreparedStatement`!
*/
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 (this.getCount() > 0) {
// Order by two fields to make a full order by
limitAndOffset.add(" ORDER BY spec_uri ASC LIMIT ?");
if (this.getStart() > 0) {
limitAndOffset.add(" OFFSET ?");
}
}
// 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 && limitAndOffset.size() == 0) {
throw new IOException("At least one condition is required to query flow configs.");
}
return baseStatement + String.join(" AND ", conditions) + String.join(" ", limitAndOffset);
}