mirror of https://github.com/apache/druid.git
Merge pull request #115 from metamx/argument-checks
add argument checks to dim filters
This commit is contained in:
commit
4b11e1db51
|
@ -22,9 +22,10 @@ package com.metamx.druid.query.filter;
|
|||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -40,6 +41,8 @@ public class AndDimFilter implements DimFilter
|
|||
@JsonProperty("fields") List<DimFilter> fields
|
||||
)
|
||||
{
|
||||
fields.removeAll(Collections.singletonList(null));
|
||||
Preconditions.checkArgument(fields.size() > 0, "AND operator requires at least one field");
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package com.metamx.druid.query.filter;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.metamx.druid.query.extraction.DimExtractionFn;
|
||||
|
||||
|
||||
|
@ -42,6 +43,10 @@ public class ExtractionDimFilter implements DimFilter
|
|||
@JsonProperty("dimExtractionFn") DimExtractionFn dimExtractionFn
|
||||
)
|
||||
{
|
||||
Preconditions.checkArgument(dimension != null, "dimension must not be null");
|
||||
Preconditions.checkArgument(value != null, "value must not be null");
|
||||
Preconditions.checkArgument(dimExtractionFn != null, "extraction function must not be null");
|
||||
|
||||
this.dimension = dimension;
|
||||
this.value = value;
|
||||
this.dimExtractionFn = dimExtractionFn;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.metamx.druid.query.filter;
|
|||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
@ -17,6 +18,8 @@ public class JavaScriptDimFilter implements DimFilter
|
|||
@JsonProperty("function") String function
|
||||
)
|
||||
{
|
||||
Preconditions.checkArgument(dimension != null, "dimension must not be null");
|
||||
Preconditions.checkArgument(function != null, "function must not be null");
|
||||
this.dimension = dimension;
|
||||
this.function = function;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ package com.metamx.druid.query.filter;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
@ -38,6 +39,7 @@ public class NotDimFilter implements DimFilter
|
|||
@JsonProperty("field") DimFilter field
|
||||
)
|
||||
{
|
||||
Preconditions.checkArgument(field != null, "NOT operator requires at least one field");
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,10 @@ package com.metamx.druid.query.filter;
|
|||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -40,6 +41,8 @@ public class OrDimFilter implements DimFilter
|
|||
@JsonProperty("fields") List<DimFilter> fields
|
||||
)
|
||||
{
|
||||
fields.removeAll(Collections.singletonList(null));
|
||||
Preconditions.checkArgument(fields.size() > 0, "OR operator requires at least one field");
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package com.metamx.druid.query.filter;
|
|||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -40,6 +40,8 @@ public class RegexDimFilter implements DimFilter
|
|||
@JsonProperty("pattern") String pattern
|
||||
)
|
||||
{
|
||||
Preconditions.checkArgument(dimension != null, "dimension must not be null");
|
||||
Preconditions.checkArgument(pattern != null, "pattern must not be null");
|
||||
this.dimension = dimension;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package com.metamx.druid.query.filter;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.metamx.druid.query.search.SearchQuerySpec;
|
||||
|
||||
|
||||
|
@ -38,6 +39,9 @@ public class SearchQueryDimFilter implements DimFilter
|
|||
@JsonProperty("query") SearchQuerySpec query
|
||||
)
|
||||
{
|
||||
Preconditions.checkArgument(dimension != null, "dimension must not be null");
|
||||
Preconditions.checkArgument(query != null, "query must not be null");
|
||||
|
||||
this.dimension = dimension;
|
||||
this.query = query;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ package com.metamx.druid.query.filter;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
@ -40,6 +41,8 @@ public class SelectorDimFilter implements DimFilter
|
|||
@JsonProperty("value") String value
|
||||
)
|
||||
{
|
||||
Preconditions.checkArgument(dimension != null, "dimension must not be null");
|
||||
Preconditions.checkArgument(value != null, "value must not be null");
|
||||
this.dimension = dimension;
|
||||
this.value = value;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue