-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "minor cleanup, adds documentation and fixes annotations"
This reverts commit 217eb32. Revert "fix cast order" This reverts commit 44b5769. Revert "fixes emitting completely empty lines" This reverts commit 51e8769. Revert "add test case for person with null entries" This reverts commit c290b3b. Revert "Revert "drop entity that had mostly empty lines"" This reverts commit 274ab8a. Revert "rework CountFilter/CountSelect distinct to allow null values" This reverts commit 7bd40ab. Revert "drop entity that had mostly empty lines" This reverts commit 45245ed. Revert "merge distinctBy into column" This reverts commit ed6795c. Revert "remove discussion" This reverts commit 363155c. Revert "remove unused method" This reverts commit ab2f321. Revert "Simplify SumSelect.distinctByColumn" This reverts commit a3565da. Revert "Simplify distinct logic for CountFilter and CountSelect" This reverts commit 20f049b. Revert "fixes getDistinctByColumn" This reverts commit c658095. Revert "adds tests" This reverts commit 8c5dde6. Revert "use fallback onto getColumn" This reverts commit ecb1560. Revert "allow multiple distinctByColumns at once" This reverts commit 01f3f50.
- Loading branch information
Showing
13 changed files
with
243 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 22 additions & 24 deletions
46
.../com/bakdata/conquery/models/datasets/concepts/select/connector/specific/CountSelect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,54 @@ | ||
package com.bakdata.conquery.models.datasets.concepts.select.connector.specific; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Stream; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import com.bakdata.conquery.io.cps.CPSType; | ||
import com.bakdata.conquery.io.jackson.serializer.NsIdRefCollection; | ||
import com.bakdata.conquery.io.jackson.serializer.NsIdRef; | ||
import com.bakdata.conquery.models.datasets.Column; | ||
import com.bakdata.conquery.models.datasets.concepts.select.Select; | ||
import com.bakdata.conquery.models.query.queryplan.aggregators.Aggregator; | ||
import com.bakdata.conquery.models.query.queryplan.aggregators.DistinctValuesWrapperAggregator; | ||
import com.bakdata.conquery.models.query.queryplan.aggregators.specific.CountAggregator; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import io.dropwizard.validation.ValidationMethod; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@CPSType(id = "COUNT", base = Select.class) | ||
@NoArgsConstructor | ||
@Data | ||
public class CountSelect extends Select { | ||
|
||
@Getter | ||
@Setter | ||
private boolean distinct = false; | ||
|
||
@NsIdRefCollection | ||
@NotNull | ||
private List<Column> column; | ||
@Getter | ||
@Setter | ||
@NsIdRef | ||
private Column distinctByColumn; | ||
|
||
@Getter | ||
@Setter | ||
@NsIdRef | ||
@NotNull | ||
private Column column; | ||
|
||
@Override | ||
public Aggregator<?> createAggregator() { | ||
if (distinct) { | ||
return new DistinctValuesWrapperAggregator<>(new CountAggregator(), getColumn()); | ||
if (distinct || distinctByColumn != null) { | ||
return new DistinctValuesWrapperAggregator<>(new CountAggregator(getColumn()), getDistinctByColumn() == null ? getColumn() : getDistinctByColumn()); | ||
} | ||
return new CountAggregator(getColumn().get(0)); | ||
return new CountAggregator(getColumn()); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Column[] getRequiredColumns() { | ||
return getColumn().toArray(Column[]::new); | ||
} | ||
|
||
|
||
@JsonIgnore | ||
@ValidationMethod(message = "Cannot use multiple columns, when distinct is not set.") | ||
public boolean isMultiOnlyWhenDistinct() { | ||
if(!isDistinct()){ | ||
return getColumn().size() == 1; | ||
} | ||
|
||
return true; | ||
return Stream.of(getColumn(), getDistinctByColumn()) | ||
.filter(Objects::nonNull) | ||
.toArray(Column[]::new); | ||
} | ||
} |
Oops, something went wrong.