-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to use physical name instead of logical name to retrieve available interval #226
Changes from 1 commit
d8d2659
dbe991c
91abe7f
d094ec8
ee87d8a
52598ac
8b0c5e6
a451011
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,10 +124,9 @@ public Set<TableName> getDataSourceNames() { | |
} | ||
|
||
/** | ||
* Combines and returns intervals of all availabilities' metric columns. | ||
* Retrieve all available intervals for all columns across all the underlying datasources. | ||
* <p> | ||
* Intervals of the same metric column are associated with the same metric column key. Overlapping intervals under | ||
* the same metric column key are collapsed into single interval. | ||
* Available intervals for the same columns are unioned into a <tt>SimplifiedIntervalList</tt> | ||
* | ||
* @return a map of column to all of its available intervals in union | ||
*/ | ||
|
@@ -148,9 +147,15 @@ public Map<String, List<Interval>> getAllAvailableIntervals() { | |
} | ||
|
||
@Override | ||
public SimplifiedIntervalList getAvailableIntervals(PhysicalDataSourceConstraint constraints) { | ||
public SimplifiedIntervalList getAvailableIntervals(PhysicalDataSourceConstraint constraint) { | ||
|
||
// If there are columns requested that are not configured on this table | ||
if (constraint.getAllColumnPhysicalNames().size() != constraint.getAllColumnNames().size()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will likely always be true, due to the defaulting behavior of how mapping from |
||
return new SimplifiedIntervalList(); | ||
} | ||
|
||
return new SimplifiedIntervalList( | ||
constructSubConstraint(constraints).entrySet().stream() | ||
constructSubConstraint(constraint).entrySet().stream() | ||
.map(entry -> entry.getKey().getAvailableIntervals(entry.getValue())) | ||
.map(simplifiedIntervalList -> (Set<Interval>) new HashSet<>(simplifiedIntervalList)) | ||
.reduce(null, IntervalUtils::getOverlappingSubintervals) | ||
|
@@ -169,7 +174,7 @@ public String toString() { | |
} | ||
|
||
/** | ||
* Validates whether the metric columns are unique accross each of the underlying datasource. | ||
* Validates whether the metric columns are unique across each of the underlying datasource. | ||
* | ||
* @param availabilityToMetricNames A map from <tt>Availability</tt> to set of <tt>MetricColumn</tt> | ||
* contained in that <tt>Availability</tt> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ package com.yahoo.bard.webservice.table.availability | |
|
||
import com.yahoo.bard.webservice.data.config.names.TableName | ||
import com.yahoo.bard.webservice.data.metric.MetricColumn | ||
import com.yahoo.bard.webservice.data.time.ZonedTimeGrain | ||
import com.yahoo.bard.webservice.table.Column | ||
import com.yahoo.bard.webservice.table.PhysicalTable | ||
import com.yahoo.bard.webservice.table.PhysicalTableSchema | ||
import com.yahoo.bard.webservice.table.resolver.DataSourceConstraint | ||
import com.yahoo.bard.webservice.table.resolver.PhysicalDataSourceConstraint | ||
import com.yahoo.bard.webservice.table.resolver.PhysicalDataSourceConstraintSpec | ||
import com.yahoo.bard.webservice.util.SimplifiedIntervalList | ||
|
||
import org.joda.time.Interval | ||
|
@@ -171,14 +172,14 @@ class MetricUnionAvailabilitySpec extends Specification { | |
|
||
} | ||
|
||
def "constructSubConstraint correctly intersect metrics configured on the table with the metrics supported by availability's underlying datasource"() { | ||
def "constructSubConstraint correctly intersects metrics configured on the table with the metrics supported by availability's underlying datasource"() { | ||
given: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. subject/verb agreement: 'intersects' |
||
availability1.getAllAvailableIntervals() >> [ | ||
(metric1): [] | ||
] | ||
availability2.getAllAvailableIntervals() >> [ | ||
(metric2): [], | ||
'ignored1': [] | ||
'un_requested': [] | ||
] | ||
|
||
metricUnionAvailability = new MetricUnionAvailability(physicalTables, [metricColumn1, metricColumn2] as Set) | ||
|
@@ -187,10 +188,10 @@ class MetricUnionAvailabilitySpec extends Specification { | |
[] as Set, | ||
[] as Set, | ||
[] as Set, | ||
[metric1, metric2, 'ignored2'] as Set, | ||
[metric1, metric2, 'un_configured'] as Set, | ||
[] as Set, | ||
[] as Set, | ||
[metric1, metric2, 'ignored2'] as Set, | ||
[metric1, metric2, 'un_configured'] as Set, | ||
[:] | ||
) | ||
|
||
|
@@ -251,4 +252,38 @@ class MetricUnionAvailabilitySpec extends Specification { | |
['2017-01-01/2017-02-01'] | ['2017-01-01/2017-01-15'] | ['2017-01-01/2017-01-15'] | "full back overlap (0/10, 0/5)" | ||
['2017-01-01/2017-02-01'] | ['2017-01-15/2017-01-25'] | ['2017-01-15/2017-01-25'] | "fully contain (0/10, 3/9)" | ||
} | ||
|
||
def "getAvailableInterval requesting un-configured column on the table will result in empty available interval"() { | ||
given: | ||
Interval interval = new Interval('2000-01-01/3000-01-01') | ||
availability1.getAllAvailableIntervals() >> [ | ||
(metric1): [interval] | ||
] | ||
availability2.getAllAvailableIntervals() >> [ | ||
(metric2): [interval] | ||
] | ||
|
||
availability1.getAvailableIntervals(_ as PhysicalDataSourceConstraint) >> new SimplifiedIntervalList([interval]) | ||
availability2.getAvailableIntervals(_ as PhysicalDataSourceConstraint) >> new SimplifiedIntervalList([interval]) | ||
|
||
metricUnionAvailability = new MetricUnionAvailability(physicalTables, [metricColumn1, metricColumn2] as Set) | ||
|
||
DataSourceConstraint dataSourceConstraint = new DataSourceConstraint( | ||
[] as Set, | ||
[] as Set, | ||
[] as Set, | ||
[metric1, metric2, 'un_configured'] as Set, | ||
[] as Set, | ||
[] as Set, | ||
[metric1, metric2, 'un_configured'] as Set, | ||
[:] | ||
) | ||
|
||
PhysicalTableSchema physicalTableSchema = new PhysicalTableSchema(Mock(ZonedTimeGrain), [new Column(metric1), new Column(metric2)], [:]) | ||
|
||
PhysicalDataSourceConstraint physicalDataSourceConstraint = new PhysicalDataSourceConstraint(dataSourceConstraint, physicalTableSchema) | ||
|
||
expect: | ||
metricUnionAvailability.getAvailableIntervals(physicalDataSourceConstraint) == new SimplifiedIntervalList() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Availbility -> Availability