@Override public Map<Column, SimplifiedIntervalList> getAllAvailableIntervals() { return mapToSchemaAvailability( getAvailability().getAllAvailableIntervals(), getSchema() ); }
@Override public String getPhysicalColumnName(String logicalName) { if (!getSchema().containsLogicalName(logicalName)) { LOG.warn( "No mapping found for logical name '{}' to physical name on table '{}'. Will use logical name as " + "physical name. This is unexpected and should not happen for properly configured " + "dimensions.", logicalName, getName() ); } return getSchema().getPhysicalColumnName(logicalName); }
@Override public SimplifiedIntervalList getAvailableIntervals(DataSourceConstraint constraint) { validateConstraintSchema(constraint); return getAvailability().getAvailableIntervals(new PhysicalDataSourceConstraint(constraint, getSchema())); }
@Override public DateTime getTableAlignment() { return getSchema().getTimeGrain().roundFloor( IntervalUtils.firstMoment(getAllAvailableIntervals().values()).orElse(new DateTime()) ); }
/** * Create a constrained copy of this table. * * @param constraint The dataSourceConstraint which narrows the view of the underlying availability * * @return a constrained table whose availability and serialization are narrowed by this constraint */ @Override public ConstrainedTable withConstraint(DataSourceConstraint constraint) { validateConstraintSchema(constraint); return new ConstrainedTable(this, new PhysicalDataSourceConstraint(constraint, getSchema())); }
@Override public Set<DataSourceName> getDataSourceNames() { // TODO: Once the availability setter is removed from this class, move this to the constructor return getAvailability().getDataSourceNames().stream() .collect(Collectors.collectingAndThen(Collectors.toSet(), Collections::unmodifiableSet)); }
@Override public String toString() { return String.format("%s datasourceName: %s ", super.toString(), getDataSourceName()); } }
@Override public SimplifiedIntervalList getAvailableIntervals() { return getAvailability().getAvailableIntervals(); }
/** * Ensure that the schema of the constraint is consistent with what the table supports. * * @param constraint The constraint being tested * * @throws IllegalArgumentException If there are columns referenced by the constraint unavailable in the table */ private void validateConstraintSchema(DataSourceConstraint constraint) throws IllegalArgumentException { Set<String> tableColumnNames = getSchema().getColumnNames(); // Validate that the requested columns are answerable by the current table if (!constraint.getAllColumnNames().stream().allMatch(tableColumnNames::contains)) { String message = String.format( "Received invalid request requesting for columns: %s that is not available in this table: %s", constraint.getAllColumnNames().stream() .filter(name -> !tableColumnNames.contains(name)) .collect(Collectors.joining(",")), getName() ); LOG.error(message); throw new IllegalArgumentException(message); } }