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);
}
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);
}
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);
}
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;
}
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();
}
}
Aggregations