jasonk000 commented on a change in pull request #12177:
URL: https://github.com/apache/druid/pull/12177#discussion_r789039127
##########
File path:
core/src/main/java/org/apache/druid/java/util/common/parsers/JSONPathFieldSpec.java
##########
@@ -23,32 +23,55 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
+import java.util.List;
import java.util.Objects;
public class JSONPathFieldSpec
{
private final JSONPathFieldType type;
private final String name;
private final String expr;
+ private final List<String> exprs;
@JsonCreator
public JSONPathFieldSpec(
@JsonProperty("type") JSONPathFieldType type,
@JsonProperty("name") String name,
- @JsonProperty("expr") String expr
+ @JsonProperty("expr") String expr,
+ @JsonProperty("exprs") List<String> exprs
)
{
this.type = type;
this.name = Preconditions.checkNotNull(name, "Missing 'name' in field
spec");
- // If expr is null and type is root, use the name as the expr too.
- if (expr == null && type == JSONPathFieldType.ROOT) {
- this.expr = name;
- } else {
- this.expr = Preconditions.checkNotNull(expr, "Missing 'expr' for
field[%s]", name);
+ // Validate required fields are present
+ switch (type) {
+ case ROOT:
+ this.expr = (expr == null) ? name : expr;
+ this.exprs = null;
+ break;
+
+ case TREE:
+ this.expr = null;
+ this.exprs = Preconditions.checkNotNull(exprs, "Missing 'exprs' for
field[%s]", name);
+ Preconditions.checkArgument(this.exprs.size() >= 1, "Need at least one
'exprs' value for field[%s]", name);
Review comment:
thanks for the tip, fixed in 672e039e519728bde493bf2ab076df9d586db4f9.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]