@Override
public ConfigPhysicalTable build(ResourceDictionaries dictionaries, DataSourceMetadataService metadataService) {
try {
Map<ConfigPhysicalTable, Set<String>> tableMetricNamesMap = getTableToMetricsMap(dictionaries);
validateDependentMetrics(tableMetricNamesMap);
return new BaseCompositePhysicalTable(
getName(),
getTimeGrain(),
buildColumns(dictionaries.getDimensionDictionary()),
tableMetricNamesMap.keySet(),
getLogicalToPhysicalNames(),
MetricUnionAvailability.build(
tableMetricNamesMap.keySet(), tableMetricNamesMap.entrySet().stream()
.collect(Collectors.toMap(
entry -> entry.getKey().getAvailability(),
Map.Entry::getValue
)))
);
} catch (IllegalArgumentException e) {
String message = String.format(VALIDATION_ERROR_FORMAT, e.getMessage());
LOG.error(message);
throw new IllegalArgumentException(message);
}
}