use of com.bakdata.conquery.models.query.queryplan.DateAggregator in project conquery by bakdata.
the class EntityDateQueryPlan method execute.
@Override
public Optional<MultilineEntityResult> execute(QueryExecutionContext ctx, Entity entity) {
// Don't set the query date aggregator here because the subqueries should set their aggregator independently
// Execute the prerequisite query
Optional<EntityResult> preResult = query.execute(ctx, entity);
if (preResult.isEmpty()) {
return Optional.empty();
}
Optional<DateAggregator> validityDateAggregator = query.getValidityDateAggregator();
if (validityDateAggregator.isEmpty()) {
return Optional.empty();
}
final CDateSet aggregationResult = validityDateAggregator.get().createAggregationResult();
aggregationResult.retainAll(dateRestriction);
// Generate DateContexts in the provided resolutions
List<DateContext> contexts = new ArrayList<>();
for (CDateRange range : aggregationResult.asRanges()) {
contexts.addAll(DateContext.generateAbsoluteContexts(range, resolutionsAndAlignments));
}
FormQueryPlan resolutionQuery = new FormQueryPlan(contexts, features);
return resolutionQuery.execute(ctx, entity);
}
use of com.bakdata.conquery.models.query.queryplan.DateAggregator in project conquery by bakdata.
the class RelativeFormQueryPlan method getValidityDateAggregator.
@Override
public Optional<Aggregator<CDateSet>> getValidityDateAggregator() {
DateAggregator agg = new DateAggregator(DateAggregationAction.MERGE);
featureSubquery.getValidityDateAggregator().ifPresent(agg::register);
outcomeSubquery.getValidityDateAggregator().ifPresent(agg::register);
return agg.hasChildren() ? Optional.of(agg) : Optional.empty();
}
Aggregations