Search in sources :

Example 16 with ConceptQuery

use of com.bakdata.conquery.apiv1.query.ConceptQuery in project conquery by bakdata.

the class QueryCleanupTaskTest method reusedOtherName.

@Test
void reusedOtherName() throws Exception {
    assertThat(STORAGE.getAllExecutions()).isEmpty();
    final ManagedQuery managedQuery = createManagedQuery();
    managedQuery.setLabel("test2");
    final ManagedQuery managedQueryReused = createManagedQuery();
    managedQuery.setQuery(new ConceptQuery(new CQReusedQuery(managedQueryReused.getId())));
    new QueryCleanupTask(STORAGE, queryExpiration).execute(Map.of(), null);
    assertThat(STORAGE.getAllExecutions()).containsExactlyInAnyOrder(managedQueryReused, managedQuery);
}
Also used : CQReusedQuery(com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) Test(org.junit.jupiter.api.Test)

Example 17 with ConceptQuery

use of com.bakdata.conquery.apiv1.query.ConceptQuery in project conquery by bakdata.

the class QueryCleanupTaskTest method reusedBothNames.

@Test
void reusedBothNames() throws Exception {
    assertThat(STORAGE.getAllExecutions()).isEmpty();
    final ManagedQuery managedQuery = createManagedQuery();
    managedQuery.setLabel("test1");
    final ManagedQuery managedQueryReused = createManagedQuery();
    managedQueryReused.setLabel("test2");
    managedQuery.setQuery(new ConceptQuery(new CQReusedQuery(managedQueryReused.getId())));
    new QueryCleanupTask(STORAGE, queryExpiration).execute(Map.of(), null);
    assertThat(STORAGE.getAllExecutions()).containsExactlyInAnyOrder(managedQuery, managedQueryReused);
}
Also used : CQReusedQuery(com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) Test(org.junit.jupiter.api.Test)

Example 18 with ConceptQuery

use of com.bakdata.conquery.apiv1.query.ConceptQuery in project conquery by bakdata.

the class QueryCleanupTaskTest method reusedYoung.

@Test
void reusedYoung() throws Exception {
    assertThat(STORAGE.getAllExecutions()).isEmpty();
    final ManagedQuery managedQuery = createManagedQuery();
    final ManagedQuery managedQueryReused = createManagedQuery();
    managedQueryReused.setCreationTime(LocalDateTime.now());
    managedQuery.setQuery(new ConceptQuery(new CQReusedQuery(managedQueryReused.getId())));
    new QueryCleanupTask(STORAGE, queryExpiration).execute(Map.of(), null);
    assertThat(STORAGE.getAllExecutions()).containsExactlyInAnyOrder(managedQueryReused);
}
Also used : CQReusedQuery(com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) Test(org.junit.jupiter.api.Test)

Example 19 with ConceptQuery

use of com.bakdata.conquery.apiv1.query.ConceptQuery in project conquery by bakdata.

the class RelExportGenerator method setInfos.

/**
 * Wraps the feature/outcome query with the corresponding info, if it is a feature or outcome
 * do generate a ColumnDescriptor later on.
 */
private static ArrayConceptQuery setInfos(ArrayConceptQuery arrayQuery, FeatureGroup group) {
    for (ConceptQuery childQueries : arrayQuery.getChildQueries()) {
        ResultInfoDecorator decorator = new ResultInfoDecorator(ImmutableClassToInstanceMap.of(FeatureGroup.class, group), childQueries.getRoot());
        childQueries.setRoot(decorator);
    }
    return arrayQuery;
}
Also used : FeatureGroup(com.bakdata.conquery.apiv1.forms.FeatureGroup) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) ArrayConceptQuery(com.bakdata.conquery.apiv1.query.ArrayConceptQuery) ResultInfoDecorator(com.bakdata.conquery.apiv1.query.concept.specific.ResultInfoDecorator)

Example 20 with ConceptQuery

use of com.bakdata.conquery.apiv1.query.ConceptQuery 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

ConceptQuery (com.bakdata.conquery.apiv1.query.ConceptQuery)20 ManagedQuery (com.bakdata.conquery.models.query.ManagedQuery)16 CQReusedQuery (com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery)10 CQConcept (com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)8 Test (org.junit.jupiter.api.Test)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 CsvSource (org.junit.jupiter.params.provider.CsvSource)6 CQAnd (com.bakdata.conquery.apiv1.query.concept.specific.CQAnd)5 CQExternal (com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal)5 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)4 Dataset (com.bakdata.conquery.models.datasets.Dataset)4 ArrayConceptQuery (com.bakdata.conquery.apiv1.query.ArrayConceptQuery)2 FilterValue (com.bakdata.conquery.apiv1.query.concept.filter.FilterValue)2 Table (com.bakdata.conquery.models.datasets.Table)2 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)2 UUID (java.util.UUID)2 FullExecutionStatus (com.bakdata.conquery.apiv1.FullExecutionStatus)1 FeatureGroup (com.bakdata.conquery.apiv1.forms.FeatureGroup)1 ExternalUploadResult (com.bakdata.conquery.apiv1.query.ExternalUploadResult)1 Query (com.bakdata.conquery.apiv1.query.Query)1