use of com.bakdata.conquery.models.query.DateAggregationMode in project conquery by bakdata.
the class SecondaryIdQuery method resolve.
@Override
public void resolve(final QueryResolveContext context) {
DateAggregationMode resolvedDateAggregationMode = dateAggregationMode;
if (context.getDateAggregationMode() != null) {
log.trace("Overriding date aggregation mode ({}) with mode from context ({})", dateAggregationMode, context.getDateAggregationMode());
resolvedDateAggregationMode = context.getDateAggregationMode();
}
final QueryResolveContext resolvedContext = context.withDateAggregationMode(resolvedDateAggregationMode);
this.query = new ConceptQuery(root);
query.resolve(resolvedContext);
withSecondaryId = new HashSet<>();
withoutSecondaryId = new HashSet<>();
// TODO FK: can we refactor this into methods of CQConcept?
// partition tables by their holding of the requested SecondaryId.
// This assumes that from the root, only ConceptNodes hold TableIds we are interested in.
query.visit(queryElement -> {
if (!(queryElement instanceof CQConcept)) {
return;
}
final CQConcept concept = (CQConcept) queryElement;
for (CQTable connector : concept.getTables()) {
final Table table = connector.getConnector().getTable();
final Column secondaryIdColumn = findSecondaryIdColumn(table);
if (secondaryIdColumn != null && !concept.isExcludeFromSecondaryId()) {
withSecondaryId.add(secondaryIdColumn);
} else {
withoutSecondaryId.add(table);
}
}
});
// If there are no tables with the secondaryId, we fail as that is user error.
if (withSecondaryId.isEmpty()) {
throw new ConqueryError.NoSecondaryIdSelectedError();
}
}
Aggregations