/** * Template Query constructor for a nested template query with a bound time grain. * * @param aggregations aggregations for this query template * @param postAggregations post aggregations for this query template * @param nestedQuery A query which this query uses as a data source * @param timeGrain The time grain constraint on the query if any */ public TemplateDruidQuery( Collection<Aggregation> aggregations, Collection<PostAggregation> postAggregations, TemplateDruidQuery nestedQuery, ZonelessTimeGrain timeGrain ) { // Convert the sets to LinkedHashSet to preserve order, and then make them unmodifiable this.aggregations = Collections.unmodifiableSet(new LinkedHashSet<>(aggregations)); this.postAggregations = Collections.unmodifiableSet(new LinkedHashSet<>(postAggregations)); this.nestedQuery = nestedQuery; this.timeGrain = timeGrain; // Check for duplicate field names Set<String> nameCollisions = getNameCollisions(aggregations, postAggregations); if (!nameCollisions.isEmpty()) { String message = "Duplicate name in aggregation & post aggregations: " + nameCollisions; LOG.error(message); throw new IllegalArgumentException(message); } depth = calculateDepth(this); }