Search in sources :

Example 1 with QueryResolveContext

use of com.bakdata.conquery.models.query.QueryResolveContext in project conquery by bakdata.

the class ManagedForm method doInitExecutable.

@Override
public void doInitExecutable(@NonNull DatasetRegistry datasetRegistry, ConqueryConfig config) {
    // init all subqueries
    submittedForm.resolve(new QueryResolveContext(getDataset(), datasetRegistry, config, null));
    subQueries = submittedForm.createSubQueries(datasetRegistry, super.getOwner(), getDataset());
    subQueries.values().stream().flatMap(List::stream).forEach(mq -> mq.initExecutable(datasetRegistry, config));
}
Also used : QueryResolveContext(com.bakdata.conquery.models.query.QueryResolveContext)

Example 2 with QueryResolveContext

use of com.bakdata.conquery.models.query.QueryResolveContext 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();
    }
}
Also used : CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) Table(com.bakdata.conquery.models.datasets.Table) Column(com.bakdata.conquery.models.datasets.Column) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) DateAggregationMode(com.bakdata.conquery.models.query.DateAggregationMode) QueryResolveContext(com.bakdata.conquery.models.query.QueryResolveContext)

Aggregations

QueryResolveContext (com.bakdata.conquery.models.query.QueryResolveContext)2 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)1 CQConcept (com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)1 Column (com.bakdata.conquery.models.datasets.Column)1 Table (com.bakdata.conquery.models.datasets.Table)1 DateAggregationMode (com.bakdata.conquery.models.query.DateAggregationMode)1