From 189beb578d648f4446bef26181210d75a2cd84b1 Mon Sep 17 00:00:00 2001
From: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
Date: Thu, 28 Oct 2021 21:06:37 +0200
Subject: [PATCH 1/3] adds more documentation
---
.../apiv1/query/SecondaryIdQuery.java | 9 +-
.../concept/specific/external/CQExternal.java | 2 +-
.../query/queryplan/SecondaryIdQueryPlan.java | 8 +-
.../specific/ConstantValueAggregator.java | 6 +-
.../queryplan/specific/ExternalNode.java | 34 +++---
.../SECONDARY_IDS.test.json | 114 ++++++++++++++++++
.../SECONDARY_ID_EXTERNAL_LOGICAL/content.csv | 7 ++
.../expected.csv | 3 +
8 files changed, 155 insertions(+), 28 deletions(-)
create mode 100644 backend/src/test/resources/tests/query/SECONDARY_ID_EXTERNAL_LOGICAL/SECONDARY_IDS.test.json
create mode 100644 backend/src/test/resources/tests/query/SECONDARY_ID_EXTERNAL_LOGICAL/content.csv
create mode 100644 backend/src/test/resources/tests/query/SECONDARY_ID_EXTERNAL_LOGICAL/expected.csv
diff --git a/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java b/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java
index 03184e4ba0..969c0943fe 100644
--- a/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java
+++ b/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java
@@ -11,6 +11,7 @@
import com.bakdata.conquery.apiv1.query.concept.filter.CQTable;
import com.bakdata.conquery.apiv1.query.concept.specific.CQConcept;
+import com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal;
import com.bakdata.conquery.io.cps.CPSType;
import com.bakdata.conquery.io.jackson.InternalOnly;
import com.bakdata.conquery.io.jackson.serializer.NsIdRef;
@@ -77,17 +78,17 @@ public void collectRequiredQueries(Set> requiredQueries) {
}
@Override
- public void resolve(QueryResolveContext context) {
+ 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();
}
- context = context.withDateAggregationMode(resolvedDateAggregationMode);
+ final QueryResolveContext resolvedContext = context.withDateAggregationMode(resolvedDateAggregationMode);
this.query = new ConceptQuery(root);
- query.resolve(context);
+ query.resolve(resolvedContext);
withSecondaryId = new HashSet<>();
withoutSecondaryId = new HashSet<>();
@@ -98,6 +99,8 @@ public void resolve(QueryResolveContext context) {
// 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 -> {
+ // We cannot check for CQExternal here and add the ALL_IDS Table because it is not serializable at the moment
+
if (!(queryElement instanceof CQConcept)) {
return;
}
diff --git a/backend/src/main/java/com/bakdata/conquery/apiv1/query/concept/specific/external/CQExternal.java b/backend/src/main/java/com/bakdata/conquery/apiv1/query/concept/specific/external/CQExternal.java
index d6143938f6..98f53465a2 100644
--- a/backend/src/main/java/com/bakdata/conquery/apiv1/query/concept/specific/external/CQExternal.java
+++ b/backend/src/main/java/com/bakdata/conquery/apiv1/query/concept/specific/external/CQExternal.java
@@ -94,7 +94,7 @@ public QPNode createQueryPlan(QueryPlanContext context, ConceptQueryPlan plan) {
}
// Allocate at once, the maximum possible size
- final Map extraAggregators = new HashMap<>(format.size());
+ final Map>> extraAggregators = new HashMap<>(format.size());
if (extra != null) {
for (int col = 0; col < format.size(); col++) {
diff --git a/backend/src/main/java/com/bakdata/conquery/models/query/queryplan/SecondaryIdQueryPlan.java b/backend/src/main/java/com/bakdata/conquery/models/query/queryplan/SecondaryIdQueryPlan.java
index 37f6a71e7b..61b08e88a6 100644
--- a/backend/src/main/java/com/bakdata/conquery/models/query/queryplan/SecondaryIdQueryPlan.java
+++ b/backend/src/main/java/com/bakdata/conquery/models/query/queryplan/SecondaryIdQueryPlan.java
@@ -72,15 +72,18 @@ public Optional execute(QueryExecutionContext ctx, Entity
return Optional.empty();
}
- //first execute only tables with secondaryIds, creating all sub-queries
+ // First execute only tables with secondaryIds, creating all sub-queries
for (Column entry : tablesWithSecondaryId) {
executeQueriesWithSecondaryId(ctx, entity, entry);
}
- //afterwards the remaining tables, since we now spawned all children
+ // Afterwards the remaining tables, since we now spawned all children
for (Table currentTable : tablesWithoutSecondaryId) {
executeQueriesWithoutSecondaryId(ctx, entity, currentTable);
}
+ // Do a last run with the ALL_IDS Table to trigger ExternalNodes
+ executeQueriesWithoutSecondaryId(ctx, entity, ctx.getStorage().getDataset().getAllIdsTable());
+
return createResult(entity);
}
@@ -117,7 +120,6 @@ private Optional createResult(Entity entity) {
public void init(QueryExecutionContext ctx, Entity entity) {
queryPlan.init(ctx, entity);
-
// Dump the created children into reuse-pool
childPlanReusePool.addAll(childPerKey.values());
diff --git a/backend/src/main/java/com/bakdata/conquery/models/query/queryplan/aggregators/specific/ConstantValueAggregator.java b/backend/src/main/java/com/bakdata/conquery/models/query/queryplan/aggregators/specific/ConstantValueAggregator.java
index a98bdde52d..9f26eb33a0 100644
--- a/backend/src/main/java/com/bakdata/conquery/models/query/queryplan/aggregators/specific/ConstantValueAggregator.java
+++ b/backend/src/main/java/com/bakdata/conquery/models/query/queryplan/aggregators/specific/ConstantValueAggregator.java
@@ -16,14 +16,14 @@
@Getter
@AllArgsConstructor
@ToString
-public class ConstantValueAggregator extends Aggregator
-### QUARTER [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/datasets/concepts/select/connector/specific/QuarterSelect.java#L14-L16)
+### QUARTER [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/datasets/concepts/select/concept/specific/QuarterSelect.java#L15-L17)
Output first, last or random Year-Quarter in time
Details
-Java Type: `com.bakdata.conquery.models.datasets.concepts.select.connector.specific.QuarterSelect`
+Java Type: `com.bakdata.conquery.models.datasets.concepts.select.concept.specific.QuarterSelect`
Supported Fields:
| | Field | Type | Default | Example | Description |
| --- | --- | --- | --- | --- | --- |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/datasets/concepts/select/Select.java#L35) | description | `String` | ? | | |
-| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/datasets/concepts/select/connector/specific/QuarterSelect.java#L22) | sample | one of EARLIEST, LATEST, RANDOM | ? | | |
+| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/datasets/concepts/select/concept/specific/QuarterSelect.java#L23) | sample | one of EARLIEST, LATEST, RANDOM | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/identifiable/Labeled.java#L25-L29) | label | `String` | ? | "someLabel" | shown in the frontend |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/identifiable/NamedImpl.java#L17) | name | `String` | ? | | |
@@ -852,5 +852,6 @@ A Marker UniversalSelect is any of:
* [EVENT_DATE_UNION](#EVENT_DATE_UNION)
* [EVENT_DURATION_SUM](#EVENT_DURATION_SUM)
* [EXISTS](#EXISTS)
+* [QUARTER](#QUARTER)
diff --git a/docs/REST API JSONs.md b/docs/REST API JSONs.md
index 4d9bf073ec..6a13a723f6 100644
--- a/docs/REST API JSONs.md
+++ b/docs/REST API JSONs.md
@@ -354,7 +354,7 @@ Supported Fields:
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/forms/managed/RelativeFormQuery.java#L49) | timeUnit | one of DAYS, QUARTERS, YEARS | ? | | |
-### SECONDARY_ID_QUERY [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L36)
+### SECONDARY_ID_QUERY [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L37)Details
@@ -365,12 +365,12 @@ Supported Fields:
| | Field | Type | Default | Example | Description |
| --- | --- | --- | --- | --- | --- |
-| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L49) | dateAggregationMode | one of NONE, MERGE, INTERSECT, LOGICAL | `"MERGE"` | | |
-| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L53-L55) | query | [CONCEPT_QUERY](#CONCEPT_QUERY) | ␀ | | |
-| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L42) | root | [@NotNull CQElement](#Base-CQElement) | `null` | | |
-| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L45) | secondaryId | ID of `@NsIdRef @NotNull SecondaryIdDescription` | `null` | | |
-| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L59) | withSecondaryId | list of ID of `@NsIdRefCollection Set` | ␀ | | |
-| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L63) | withoutSecondaryId | list of ID of `@NsIdRefCollection Set
` | ␀ | | |
+| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L50) | dateAggregationMode | one of NONE, MERGE, INTERSECT, LOGICAL | `"MERGE"` | | |
+| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L54-L56) | query | [CONCEPT_QUERY](#CONCEPT_QUERY) | ␀ | | |
+| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L43) | root | [@NotNull CQElement](#Base-CQElement) | `null` | | |
+| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L46) | secondaryId | ID of `@NsIdRef @NotNull SecondaryIdDescription` | `null` | | |
+| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L60) | withSecondaryId | list of ID of `@NsIdRefCollection Set` | ␀ | | |
+| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/SecondaryIdQuery.java#L64) | withoutSecondaryId | list of ID of `@NsIdRefCollection Set