/** * Constructor. * * @param dataSourceConstraint Data source constraint containing all the column names as logical names * @param physicalTableSchema A map from logical column name to physical column names */ public PhysicalDataSourceConstraint( @NotNull DataSourceConstraint dataSourceConstraint, @NotNull PhysicalTableSchema physicalTableSchema ) { super(dataSourceConstraint); this.allColumnPhysicalNames = dataSourceConstraint.getAllColumnNames().stream() .map(physicalTableSchema::getPhysicalColumnName) .collect(Collectors.collectingAndThen(Collectors.toSet(), Collections::unmodifiableSet)); }
/** * 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); } }
/** * Copy Constructor. * * @param dataSourceConstraint The data source constraint to copy from */ protected DataSourceConstraint(DataSourceConstraint dataSourceConstraint) { this.requestDimensions = dataSourceConstraint.getRequestDimensions(); this.filterDimensions = dataSourceConstraint.getFilterDimensions(); this.metricDimensions = dataSourceConstraint.getMetricDimensions(); this.metricNames = dataSourceConstraint.getMetricNames(); this.apiFilters = dataSourceConstraint.getApiFilters(); this.allDimensions = dataSourceConstraint.getAllDimensions(); this.allDimensionNames = dataSourceConstraint.getAllDimensionNames(); this.allColumnNames = dataSourceConstraint.getAllColumnNames(); }