From e12a4728605924c40752ce15d82e1bfa6b797677 Mon Sep 17 00:00:00 2001 From: Michael McLawhorn Date: Thu, 9 Nov 2017 13:23:32 -0600 Subject: [PATCH 1/2] Forced type safety on DSC constructors --- .../table/resolver/DataSourceConstraint.java | 43 ++++++++++--------- .../resolver/QueryPlanningConstraint.java | 5 +-- .../bard/webservice/web/DataApiRequest.java | 5 ++- .../bard/webservice/web/TablesApiRequest.java | 9 ++-- .../web/apirequest/ApiRequestImpl.java | 7 ++- .../web/apirequest/DataApiRequestImpl.java | 9 ++-- .../web/apirequest/TablesApiRequestImpl.java | 9 ++-- .../webservice/web/filters/ApiFilters.java | 31 +++++++++++++ .../MetricUnionAvailabilitySpec.groovy | 11 +++-- .../resolver/DataSourceConstraintSpec.groovy | 5 ++- .../PhysicalDataSourceConstraintSpec.groovy | 4 +- .../RoleDimensionApiFilterRequestMapper.java | 8 ++-- .../builders/SimpleDruidQueryBuilder.groovy | 4 +- 13 files changed, 98 insertions(+), 52 deletions(-) create mode 100644 fili-core/src/main/java/com/yahoo/bard/webservice/web/filters/ApiFilters.java diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/table/resolver/DataSourceConstraint.java b/fili-core/src/main/java/com/yahoo/bard/webservice/table/resolver/DataSourceConstraint.java index 28d566f842..84cbe2a969 100644 --- a/fili-core/src/main/java/com/yahoo/bard/webservice/table/resolver/DataSourceConstraint.java +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/table/resolver/DataSourceConstraint.java @@ -5,17 +5,18 @@ import com.yahoo.bard.webservice.data.dimension.Dimension; import com.yahoo.bard.webservice.druid.model.query.DruidAggregationQuery; import com.yahoo.bard.webservice.table.PhysicalTable; -import com.yahoo.bard.webservice.web.ApiFilter; import com.yahoo.bard.webservice.web.DataApiRequest; +import com.yahoo.bard.webservice.web.filters.ApiFilters; import java.util.Collections; -import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.validation.constraints.NotNull; + /** * Constraints for retrieving potential table availability for a given query. */ @@ -26,7 +27,7 @@ public class DataSourceConstraint { private final Set filterDimensions; private final Set metricDimensions; private final Set metricNames; - private final Map> apiFilters; + private final ApiFilters apiFilters; // Calculated fields private final Set allDimensions; @@ -44,7 +45,7 @@ public DataSourceConstraint(DataApiRequest dataApiRequest, DruidAggregationQuery this.filterDimensions = Collections.unmodifiableSet(dataApiRequest.getFilterDimensions()); this.metricDimensions = Collections.unmodifiableSet(templateDruidQuery.getMetricDimensions()); this.metricNames = Collections.unmodifiableSet(templateDruidQuery.getDependentFieldNames()); - this.apiFilters = Collections.unmodifiableMap(dataApiRequest.getApiFilters()); + this.apiFilters = new ApiFilters(dataApiRequest.getApiFilters()); this.allDimensions = generateAllDimensions(); this.allDimensionNames = generateAllDimensionNames(); this.allColumnNames = generateAllColumnNames(); @@ -60,11 +61,11 @@ public DataSourceConstraint(DataApiRequest dataApiRequest, DruidAggregationQuery * @param apiFilters Map of dimension to its set of API filters */ protected DataSourceConstraint( - Set requestDimensions, - Set filterDimensions, - Set metricDimensions, - Set metricNames, - Map> apiFilters + @NotNull Set requestDimensions, + @NotNull Set filterDimensions, + @NotNull Set metricDimensions, + @NotNull Set metricNames, + @NotNull ApiFilters apiFilters ) { this.requestDimensions = Collections.unmodifiableSet(requestDimensions); this.filterDimensions = Collections.unmodifiableSet(filterDimensions); @@ -89,18 +90,19 @@ protected DataSourceConstraint( * @param apiFilters Map of dimension to its set of API filters * * @deprecated "allDimensions", "allDimensionNames", and "allColumnNames" can be generated by other arguments. Use - * {@link #DataSourceConstraint(Set, Set, Set, Set, Map)} instead, which saves caller argument-passing efforts. + * {@link #DataSourceConstraint(Set, Set, Set, Set, ApiFilters)} instead, which saves caller argument-passing + * efforts. */ @Deprecated protected DataSourceConstraint( - Set requestDimensions, - Set filterDimensions, - Set metricDimensions, - Set metricNames, - Set allDimensions, - Set allDimensionNames, - Set allColumnNames, - Map> apiFilters + @NotNull Set requestDimensions, + @NotNull Set filterDimensions, + @NotNull Set metricDimensions, + @NotNull Set metricNames, + @NotNull Set allDimensions, + @NotNull Set allDimensionNames, + @NotNull Set allColumnNames, + @NotNull ApiFilters apiFilters ) { this.requestDimensions = requestDimensions; this.filterDimensions = filterDimensions; @@ -156,7 +158,7 @@ public Set getAllColumnNames() { return allColumnNames; } - public Map> getApiFilters() { + public ApiFilters getApiFilters() { return apiFilters; } @@ -205,7 +207,7 @@ public static DataSourceConstraint unconstrained(PhysicalTable table) { .map(Dimension::getApiName) .collect(Collectors.toSet()), table.getSchema().getColumnNames(), - Collections.emptyMap() + new ApiFilters(Collections.emptyMap()) ); } @@ -222,7 +224,6 @@ public boolean equals(final Object obj) { && Objects.equals(this.metricNames, that.metricNames) && Objects.equals(this.apiFilters, that.apiFilters); } - return false; } diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/table/resolver/QueryPlanningConstraint.java b/fili-core/src/main/java/com/yahoo/bard/webservice/table/resolver/QueryPlanningConstraint.java index 5bade6be81..59c001ba10 100644 --- a/fili-core/src/main/java/com/yahoo/bard/webservice/table/resolver/QueryPlanningConstraint.java +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/table/resolver/QueryPlanningConstraint.java @@ -7,14 +7,13 @@ import com.yahoo.bard.webservice.data.metric.TemplateDruidQuery; import com.yahoo.bard.webservice.druid.model.query.Granularity; import com.yahoo.bard.webservice.table.LogicalTable; -import com.yahoo.bard.webservice.web.ApiFilter; import com.yahoo.bard.webservice.web.DataApiRequest; import com.yahoo.bard.webservice.web.TablesApiRequest; +import com.yahoo.bard.webservice.web.filters.ApiFilters; import org.joda.time.Interval; import java.util.Collections; -import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -52,7 +51,7 @@ public QueryPlanningConstraint( Set filterDimensions, Set metricDimensions, Set metricNames, - Map> apiFilters, + ApiFilters apiFilters, LogicalTable logicalTable, Set intervals, Set logicalMetrics, diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/web/DataApiRequest.java b/fili-core/src/main/java/com/yahoo/bard/webservice/web/DataApiRequest.java index 109bbc75c7..931f7ae32a 100644 --- a/fili-core/src/main/java/com/yahoo/bard/webservice/web/DataApiRequest.java +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/web/DataApiRequest.java @@ -13,6 +13,7 @@ import com.yahoo.bard.webservice.druid.model.query.Granularity; import com.yahoo.bard.webservice.table.LogicalTable; import com.yahoo.bard.webservice.web.apirequest.DataApiRequestImpl; +import com.yahoo.bard.webservice.web.filters.ApiFilters; import com.yahoo.bard.webservice.web.util.PaginationParameters; import org.joda.time.DateTimeZone; @@ -155,7 +156,7 @@ public interface DataApiRequest extends ApiRequest { * * @return a map of filters by dimension */ - Map> getApiFilters(); + ApiFilters getApiFilters(); /** * Generates filter objects on the based on the filter query in the api request. @@ -195,7 +196,7 @@ DataApiRequestImpl withPerDimensionFields(LinkedHashMap intervals); - DataApiRequestImpl withFilters(Map> filters); + DataApiRequestImpl withFilters(ApiFilters filters); DataApiRequestImpl withHavings(Map> havings); diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/web/TablesApiRequest.java b/fili-core/src/main/java/com/yahoo/bard/webservice/web/TablesApiRequest.java index 2fd211fedd..ab94b110f4 100644 --- a/fili-core/src/main/java/com/yahoo/bard/webservice/web/TablesApiRequest.java +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/web/TablesApiRequest.java @@ -6,15 +6,18 @@ import com.yahoo.bard.webservice.data.metric.LogicalMetric; import com.yahoo.bard.webservice.druid.model.query.Granularity; import com.yahoo.bard.webservice.table.LogicalTable; +import com.yahoo.bard.webservice.web.filters.ApiFilters; import com.yahoo.bard.webservice.web.util.PaginationParameters; + import org.joda.time.Interval; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; import java.util.Map; import java.util.Optional; import java.util.Set; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + /** * Tables API Request. Such an API Request binds, validates, and models the parts of a request to the tables endpoint. */ @@ -61,7 +64,7 @@ public interface TablesApiRequest extends ApiRequest { * * @return the map of filters by dimension for this request, grouped by dimensions */ - Map> getApiFilters(); + ApiFilters getApiFilters(); /** * Returns the intervals for this query. diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/ApiRequestImpl.java b/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/ApiRequestImpl.java index 1ac4400d81..cd9d456f4b 100644 --- a/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/ApiRequestImpl.java +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/ApiRequestImpl.java @@ -41,6 +41,7 @@ import com.yahoo.bard.webservice.web.FilterOperation; import com.yahoo.bard.webservice.web.ResponseFormatType; import com.yahoo.bard.webservice.web.TimeMacros; +import com.yahoo.bard.webservice.web.filters.ApiFilters; import com.yahoo.bard.webservice.web.util.PaginationLink; import com.yahoo.bard.webservice.web.util.PaginationParameters; @@ -57,11 +58,9 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.function.Function; @@ -436,7 +435,7 @@ protected static Set generateIntervals( * contains a 'startsWith' or 'contains' operation while the BardFeatureFlag.DATA_STARTS_WITH_CONTAINS_ENABLED is * off. */ - public Map> generateFilters( + public ApiFilters generateFilters( String filterQuery, LogicalTable table, DimensionDictionary dimensionDictionary @@ -444,7 +443,7 @@ public Map> generateFilters( try (TimedPhase timer = RequestLog.startTiming("GeneratingFilters")) { LOG.trace("Dimension Dictionary: {}", dimensionDictionary); // Set of filter objects - Map> generated = new LinkedHashMap<>(); + ApiFilters generated = new ApiFilters(); // Filters are optional hence check if filters are requested. if (filterQuery == null || "".equals(filterQuery)) { diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/DataApiRequestImpl.java b/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/DataApiRequestImpl.java index cda39ce869..33d3cf2435 100644 --- a/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/DataApiRequestImpl.java +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/DataApiRequestImpl.java @@ -48,6 +48,7 @@ import com.yahoo.bard.webservice.web.FilterOperation; import com.yahoo.bard.webservice.web.MetricParser; import com.yahoo.bard.webservice.web.ResponseFormatType; +import com.yahoo.bard.webservice.web.filters.ApiFilters; import com.yahoo.bard.webservice.web.util.BardConfigResources; import com.yahoo.bard.webservice.web.util.PaginationParameters; @@ -93,7 +94,7 @@ public class DataApiRequestImpl extends ApiRequestImpl implements DataApiRequest private final LinkedHashMap> perDimensionFields; private final Set logicalMetrics; private final Set intervals; - private final Map> apiFilters; + private final ApiFilters apiFilters; private final Map> havings; private final Having having; private final LinkedHashSet sorts; @@ -326,7 +327,7 @@ protected DataApiRequestImpl( LinkedHashMap> perDimensionFields, Set logicalMetrics, Set intervals, - Map> apiFilters, + ApiFilters apiFilters, Map> havings, Having having, LinkedHashSet sorts, @@ -878,7 +879,7 @@ public DataApiRequestImpl withIntervals(Set intervals) { } @Override - public DataApiRequestImpl withFilters(Map> apiFilters) { + public DataApiRequestImpl withFilters(ApiFilters apiFilters) { return new DataApiRequestImpl(format, paginationParameters, uriInfo, builder, table, granularity, dimensions, perDimensionFields, logicalMetrics, intervals, apiFilters, havings, having, sorts, count, topN, asyncAfter, timeZone, filterBuilder, havingApiGenerator, dateTimeSort); } @@ -965,7 +966,7 @@ public Set getIntervals() { } @Override - public Map> getApiFilters() { + public ApiFilters getApiFilters() { return this.apiFilters; } diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/TablesApiRequestImpl.java b/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/TablesApiRequestImpl.java index 9be6110a50..35335ecc00 100644 --- a/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/TablesApiRequestImpl.java +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/web/apirequest/TablesApiRequestImpl.java @@ -21,6 +21,7 @@ import com.yahoo.bard.webservice.web.BadApiRequestException; import com.yahoo.bard.webservice.web.ResponseFormatType; import com.yahoo.bard.webservice.web.TablesApiRequest; +import com.yahoo.bard.webservice.web.filters.ApiFilters; import com.yahoo.bard.webservice.web.util.BardConfigResources; import com.yahoo.bard.webservice.web.util.PaginationParameters; @@ -56,7 +57,7 @@ public class TablesApiRequestImpl extends ApiRequestImpl implements TablesApiReq private final Set dimensions; private final Set logicalMetrics; private final Set intervals; - private final Map> apiFilters; + private final ApiFilters apiFilters; /** * Parses the API request URL and generates the Api Request object. @@ -104,7 +105,7 @@ public TablesApiRequestImpl( dimensions = Collections.emptySet(); logicalMetrics = Collections.emptySet(); intervals = Collections.emptySet(); - apiFilters = Collections.emptyMap(); + apiFilters = new ApiFilters(Collections.emptyMap()); LOG.debug( "Api request: Tables: {},\nGranularity: {},\nFormat: {}\nPagination: {}" + @@ -252,7 +253,7 @@ private TablesApiRequestImpl( Set dimensions, Set metrics, Set intervals, - Map> filters + ApiFilters filters ) { super(format, SYNCHRONOUS_ASYNC_AFTER_VALUE, paginationParameters, uriInfo, builder); this.tables = tables; @@ -394,7 +395,7 @@ public Set getFilterDimensions() { } @Override - public Map> getApiFilters() { + public ApiFilters getApiFilters() { return apiFilters; } diff --git a/fili-core/src/main/java/com/yahoo/bard/webservice/web/filters/ApiFilters.java b/fili-core/src/main/java/com/yahoo/bard/webservice/web/filters/ApiFilters.java new file mode 100644 index 0000000000..0398338248 --- /dev/null +++ b/fili-core/src/main/java/com/yahoo/bard/webservice/web/filters/ApiFilters.java @@ -0,0 +1,31 @@ +// Copyright 2017 Yahoo Inc. +// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms. +package com.yahoo.bard.webservice.web.filters; + +import com.yahoo.bard.webservice.data.dimension.Dimension; +import com.yahoo.bard.webservice.web.ApiFilter; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +/** + * ApiFilters specializes the type of the ApiFilterMap. + */ +public class ApiFilters extends LinkedHashMap> { + + /** + * Constructor. + */ + public ApiFilters() { + } + + /** + * Constructor. + * + * @param filters A set of filters to copy. + */ + public ApiFilters(Map> filters) { + super(filters); + } +} diff --git a/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/availability/MetricUnionAvailabilitySpec.groovy b/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/availability/MetricUnionAvailabilitySpec.groovy index 6e07ce6024..3c96bcb873 100644 --- a/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/availability/MetricUnionAvailabilitySpec.groovy +++ b/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/availability/MetricUnionAvailabilitySpec.groovy @@ -9,6 +9,7 @@ import com.yahoo.bard.webservice.table.ConfigPhysicalTable import com.yahoo.bard.webservice.table.resolver.DataSourceConstraint import com.yahoo.bard.webservice.table.resolver.PhysicalDataSourceConstraint import com.yahoo.bard.webservice.util.SimplifiedIntervalList +import com.yahoo.bard.webservice.web.filters.ApiFilters import org.joda.time.Interval @@ -35,6 +36,8 @@ class MetricUnionAvailabilitySpec extends Specification { MetricUnionAvailability metricUnionAvailability + ApiFilters apiFilters + def setup() { availability1 = Mock(Availability) availability2 = Mock(Availability) @@ -55,6 +58,8 @@ class MetricUnionAvailabilitySpec extends Specification { physicalTable2.getAvailability() >> availability2 physicalTables = [physicalTable1, physicalTable2] as Set + + apiFilters = new ApiFilters() } def "Metric columns are initialized by fetching columns from availabilities, not from physical tables"() { @@ -175,7 +180,7 @@ class MetricUnionAvailabilitySpec extends Specification { [] as Set, [] as Set, [metric1, metric2, 'un_configured'] as Set, - [:] + [:] as ApiFilters ) PhysicalDataSourceConstraint physicalDataSourceConstraint = new PhysicalDataSourceConstraint(dataSourceConstraint, [metric1, metric2, 'ignored2'] as Set) @@ -208,7 +213,7 @@ class MetricUnionAvailabilitySpec extends Specification { [] as Set, [] as Set, [metric1, metric2] as Set, - [:] + apiFilters ) PhysicalDataSourceConstraint physicalDataSourceConstraint = new PhysicalDataSourceConstraint(dataSourceConstraint, [metric1, metric2] as Set) @@ -254,7 +259,7 @@ class MetricUnionAvailabilitySpec extends Specification { [] as Set, [] as Set, [metric1, metric2, 'un_configured'] as Set, - [:] + apiFilters ) PhysicalDataSourceConstraint physicalDataSourceConstraint = new PhysicalDataSourceConstraint(dataSourceConstraint, [metric1, metric2, 'un_configured'] as Set) diff --git a/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/resolver/DataSourceConstraintSpec.groovy b/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/resolver/DataSourceConstraintSpec.groovy index 94bcb5b8ae..814503922c 100644 --- a/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/resolver/DataSourceConstraintSpec.groovy +++ b/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/resolver/DataSourceConstraintSpec.groovy @@ -2,11 +2,14 @@ // Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms. package com.yahoo.bard.webservice.table.resolver +import com.yahoo.bard.webservice.web.filters.ApiFilters + import spock.lang.Specification import spock.lang.Unroll class DataSourceConstraintSpec extends Specification { + ApiFilters apiFilters = new ApiFilters() @Unroll def "#metricNames intersected with #other produces #newMetricNames"() { given: @@ -18,7 +21,7 @@ class DataSourceConstraintSpec extends Specification { [] as Set, [] as Set, [] as Set, - [:] + apiFilters ).withMetricIntersection(other as Set) expect: diff --git a/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/resolver/PhysicalDataSourceConstraintSpec.groovy b/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/resolver/PhysicalDataSourceConstraintSpec.groovy index 2305ff6197..122bb52b0b 100644 --- a/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/resolver/PhysicalDataSourceConstraintSpec.groovy +++ b/fili-core/src/test/groovy/com/yahoo/bard/webservice/table/resolver/PhysicalDataSourceConstraintSpec.groovy @@ -3,6 +3,7 @@ package com.yahoo.bard.webservice.table.resolver import com.yahoo.bard.webservice.data.time.ZonedTimeGrain import com.yahoo.bard.webservice.table.Column import com.yahoo.bard.webservice.table.PhysicalTableSchema +import com.yahoo.bard.webservice.web.filters.ApiFilters import spock.lang.Specification @@ -14,6 +15,7 @@ class PhysicalDataSourceConstraintSpec extends Specification { DataSourceConstraint dataSourceConstraint PhysicalTableSchema physicalTableSchema PhysicalDataSourceConstraint physicalDataSourceConstraint + ApiFilters apiFilters = new ApiFilters() def setup() { dataSourceConstraint = new DataSourceConstraint( @@ -24,7 +26,7 @@ class PhysicalDataSourceConstraintSpec extends Specification { [] as Set, [] as Set, ['columnOne', 'columnTwo', 'columnThree', 'columnFour'] as Set, - [:] + apiFilters ) physicalTableSchema = new PhysicalTableSchema(Mock(ZonedTimeGrain), [new Column('columnOne'), new Column('columnTwo'), new Column('columnThree'), new Column('columnFour')], ['columnOne': 'column_one', 'columnTwo': 'column_two']) diff --git a/fili-security/src/main/java/com/yahoo/bard/webservice/web/security/RoleDimensionApiFilterRequestMapper.java b/fili-security/src/main/java/com/yahoo/bard/webservice/web/security/RoleDimensionApiFilterRequestMapper.java index 1136fa861a..560e8c63a1 100644 --- a/fili-security/src/main/java/com/yahoo/bard/webservice/web/security/RoleDimensionApiFilterRequestMapper.java +++ b/fili-security/src/main/java/com/yahoo/bard/webservice/web/security/RoleDimensionApiFilterRequestMapper.java @@ -16,6 +16,7 @@ import com.yahoo.bard.webservice.web.FilterOperation; import com.yahoo.bard.webservice.web.RequestMapper; import com.yahoo.bard.webservice.web.RequestValidationException; +import com.yahoo.bard.webservice.web.filters.ApiFilters; import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.commons.lang3.tuple.Triple; @@ -24,7 +25,6 @@ import java.security.Principal; import java.util.Collections; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.function.Function; @@ -90,7 +90,7 @@ protected DataApiRequest internalApply(DataApiRequest request, ContainerRequestC validateSecurityFilters(securityContext.getUserPrincipal(), securityFilters); - Map> revisedFilters = mergeSecurityFilters(request.getApiFilters(), securityFilters); + ApiFilters revisedFilters = mergeSecurityFilters(request.getApiFilters(), securityFilters); return request.withFilters(revisedFilters); } @@ -103,11 +103,11 @@ protected DataApiRequest internalApply(DataApiRequest request, ContainerRequestC * * @return A set of request filters supplemented with filters from this request. */ - protected Map> mergeSecurityFilters( + protected ApiFilters mergeSecurityFilters( Map> requestFilters, Set securityFilters ) { - Map> revisedFilters = new LinkedHashMap<>(requestFilters); + ApiFilters revisedFilters = new ApiFilters(requestFilters); Set requestDimensionFilters = revisedFilters.getOrDefault( dimension, Collections.emptySet() diff --git a/fili-sql/src/test/groovy/com/yahoo/bard/webservice/sql/builders/SimpleDruidQueryBuilder.groovy b/fili-sql/src/test/groovy/com/yahoo/bard/webservice/sql/builders/SimpleDruidQueryBuilder.groovy index 3cc8d009fd..4d043d9dcd 100644 --- a/fili-sql/src/test/groovy/com/yahoo/bard/webservice/sql/builders/SimpleDruidQueryBuilder.groovy +++ b/fili-sql/src/test/groovy/com/yahoo/bard/webservice/sql/builders/SimpleDruidQueryBuilder.groovy @@ -56,10 +56,10 @@ import com.yahoo.bard.webservice.table.ConfigPhysicalTable import com.yahoo.bard.webservice.table.ConstrainedTable import com.yahoo.bard.webservice.table.PhysicalTableDictionary import com.yahoo.bard.webservice.table.SqlPhysicalTable -import com.yahoo.bard.webservice.table.StrictPhysicalTable import com.yahoo.bard.webservice.table.availability.PermissiveAvailability import com.yahoo.bard.webservice.table.resolver.DataSourceConstraint import com.yahoo.bard.webservice.util.Utils +import com.yahoo.bard.webservice.web.filters.ApiFilters import org.joda.time.DateTimeZone import org.joda.time.Interval @@ -220,7 +220,7 @@ class SimpleDruidQueryBuilder { getDimensions(dimensions) as Set, dimensions as Set, metricsAndDimensions, - [:] + new ApiFilters() ) ) ) From 518bfc29171238a7cee5c8c648fee1c6fad9c661 Mon Sep 17 00:00:00 2001 From: Michael McLawhorn Date: Fri, 10 Nov 2017 17:21:53 -0600 Subject: [PATCH 2/2] Added CHANGELOG --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af2a318300..a031b7a246 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -169,6 +169,9 @@ Current ### Fixed: +- [Fix intermittent class scanner error on DataSourceConstraint equal](https://github.com/yahoo/fili/pull/573) + * Class Scanner Spec was injecting an improper dependant field due to type erasure. Made field type explicit. + - [Fix tests with wrong time offset calculation](https://github.com/yahoo/fili/pull/567) * Time-checking based tests setup time offset in a wrong way. `timeZoneId.getOffset` is fixed to take the right argument. @@ -1342,4 +1345,4 @@ Jobs resource. Here are the highlights of what's in this release: - [`DruidDimensionsLoader` doesn't set the dimension's lastUpdated date](https://github.com/yahoo/fili/pull/24) * `DruidDimensionsLoader` now properly sets the `lastUpdated` field after it finished processing the Druid response - \ No newline at end of file +