/** * Constructor for sub-class to call. * * @param name Table name of the physical table * @param timeGrain Zoned time grain of the table * @param metricNames The Set of metric names on the table * @param dimensionConfigs Set of dimensions on the table as dimension configs * @param expectedStartDate The expected start date of the datasource the constructed table will represent. Null * indicates there is NO expected start date * @param expectedEndDate The expected end date of the datasource the constructed table will represent. Null * indicates there is NO expected end date */ protected PhysicalTableDefinition( TableName name, ZonedTimeGrain timeGrain, Set<FieldName> metricNames, Set<? extends DimensionConfig> dimensionConfigs, DateTime expectedStartDate, DateTime expectedEndDate ) { this.name = name; this.timeGrain = timeGrain; this.metricNames = ImmutableSet.copyOf(metricNames); this.dimensionConfigs = ImmutableSet.copyOf(dimensionConfigs); this.logicalToPhysicalNames = Collections.unmodifiableMap(buildLogicalToPhysicalNames(dimensionConfigs)); this.expectedStartDate = expectedStartDate; this.expectedEndDate = expectedEndDate; }
/** * Helper method for sub-classes to convert dimension configs into dimension columns and create metric columns. * * @param dimensionDictionary Dictionary for dimension name to dimension columns * * @return all columns including dimension columns and metric columns */ protected Set<Column> buildColumns(DimensionDictionary dimensionDictionary) { return Stream.concat( // Load the dimension columns getDimensionConfigs().stream() .map(DimensionConfig::getApiName) .map(dimensionDictionary::findByApiName) .map(DimensionColumn::new), // And the metric columns getMetricNames().stream() .map(FieldName::asName) .map(MetricColumn::new) ).collect(Collectors.toCollection(LinkedHashSet::new)); } }
/** * Build a map from physical table name to its table definition. * * @param physicalTableDefinitions Definitions to build the map from * * @return the map of physical table name to its table definition */ private Map<String, PhysicalTableDefinition> buildPhysicalTableDefinitionDictionary( Set<PhysicalTableDefinition> physicalTableDefinitions ) { return physicalTableDefinitions.stream() .collect(Collectors.toMap(definition -> definition.getName().asName(), Function.identity())); }
/** * Load a new physical table into the dictionary and return the loaded physical table. * * @param definition A config object for the physical table * @param metricNames The Set of metric names on the table * @param dictionaries The resource dictionaries for reading and storing resource data * * @return The physical table created * * @deprecated use buildPhysicalTableWithDependency instead, which also supports building table with dependencies */ @Deprecated protected PhysicalTable loadPhysicalTable( PhysicalTableDefinition definition, Set<FieldName> metricNames, ResourceDictionaries dictionaries ) { LOG.debug( "Building table {} with deprecated loadPhysicalTable method, use buildPhysicalTableWithDependency " + "instead", definition.getName().asName() ); return definition.build(dictionaries, getDataSourceMetadataService()); }
currentTableDefinition.getDependentTableNames() .forEach( tableName -> { ConfigPhysicalTable currentTableBuilt = currentTableDefinition.build( dictionaries, getDataSourceMetadataService()