Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsrnhld committed May 29, 2024
1 parent 3ede582 commit 9790ca6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.bakdata.conquery.sql.conversion.model.QueryStep;
import com.bakdata.conquery.sql.conversion.model.select.ConnectorSqlSelects;
import com.bakdata.conquery.sql.conversion.model.select.FieldWrapper;
import com.bakdata.conquery.sql.conversion.model.select.SingleColumnSqlSelect;
import com.bakdata.conquery.sql.conversion.model.select.SqlSelect;
import lombok.Getter;

Expand All @@ -23,23 +24,23 @@
@Getter
class CommonAggregationSelect<T> {

private final List<? extends SqlSelect> rootSelects;
private final List<SingleColumnSqlSelect> rootSelects;
private final FieldWrapper<T> groupBy;
private final QueryStep additionalPredecessor;

public CommonAggregationSelect(List<? extends SqlSelect> rootSelects, FieldWrapper<T> groupBy, QueryStep additionalPredecessor) {
public CommonAggregationSelect(List<SingleColumnSqlSelect> rootSelects, FieldWrapper<T> groupBy, QueryStep additionalPredecessor) {
this.rootSelects = rootSelects;
this.groupBy = groupBy;
this.additionalPredecessor = additionalPredecessor;
}

public CommonAggregationSelect(SqlSelect rootSelect, FieldWrapper<T> groupBy) {
public CommonAggregationSelect(SingleColumnSqlSelect rootSelect, FieldWrapper<T> groupBy) {
this.rootSelects = List.of(rootSelect);
this.groupBy = groupBy;
this.additionalPredecessor = null;
}

public CommonAggregationSelect(List<? extends SqlSelect> rootSelects, FieldWrapper<T> groupBy) {
public CommonAggregationSelect(List<SingleColumnSqlSelect> rootSelects, FieldWrapper<T> groupBy) {
this.rootSelects = rootSelects;
this.groupBy = groupBy;
this.additionalPredecessor = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.bakdata.conquery.sql.conversion.model.select.FieldWrapper;
import com.bakdata.conquery.sql.conversion.model.select.SelectContext;
import com.bakdata.conquery.sql.conversion.model.select.SelectConverter;
import com.bakdata.conquery.sql.conversion.model.select.SingleColumnSqlSelect;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.jooq.Condition;
Expand Down Expand Up @@ -187,7 +188,7 @@ public Condition convertForTableExport(SumFilter<RANGE> filter, FilterContext<RA
private CommonAggregationSelect<BigDecimal> createSumAggregationSelect(Column sumColumn, Column subtractColumn, String alias, ConnectorSqlTables tables) {

Class<? extends Number> numberClass = NumberMapUtil.NUMBER_MAP.get(sumColumn.getType());
List<ExtractingSqlSelect<?>> preprocessingSelects = new ArrayList<>();
List<SingleColumnSqlSelect> preprocessingSelects = new ArrayList<>();

ExtractingSqlSelect<? extends Number> rootSelect = new ExtractingSqlSelect<>(tables.getRootTable(), sumColumn.getName(), numberClass);
preprocessingSelects.add(rootSelect);
Expand Down Expand Up @@ -223,13 +224,13 @@ private CommonAggregationSelect<BigDecimal> createDistinctSumAggregationSelect(
ConnectorSqlTables tables,
NameGenerator nameGenerator
) {
List<ExtractingSqlSelect<?>> preprocessingSelects = new ArrayList<>();
List<SingleColumnSqlSelect> preprocessingSelects = new ArrayList<>();

Class<? extends Number> numberClass = NumberMapUtil.NUMBER_MAP.get(sumColumn.getType());
ExtractingSqlSelect<? extends Number> rootSelect = new ExtractingSqlSelect<>(tables.getRootTable(), sumColumn.getName(), numberClass);
preprocessingSelects.add(rootSelect);

List<ExtractingSqlSelect<?>> distinctByRootSelects =
List<SingleColumnSqlSelect> distinctByRootSelects =
distinctByColumns.stream()
.map(column -> new ExtractingSqlSelect<>(tables.getRootTable(), column.getName(), Object.class))
.collect(Collectors.toList());
Expand All @@ -249,15 +250,15 @@ private CommonAggregationSelect<BigDecimal> createDistinctSumAggregationSelect(
*/
private static QueryStep createRowNumberCte(
SqlIdColumns ids,
ExtractingSqlSelect<? extends Number> sumColumnRootSelect,
List<ExtractingSqlSelect<?>> distinctByRootSelects,
SingleColumnSqlSelect sumColumnRootSelect,
List<SingleColumnSqlSelect> distinctByRootSelects,
String alias,
SqlTables connectorTables,
NameGenerator nameGenerator
) {
String predecessor = connectorTables.getPredecessor(ConceptCteStep.AGGREGATION_SELECT);
SqlIdColumns qualifiedIds = ids.qualify(predecessor);
ExtractingSqlSelect<?> qualifiedSumRootSelect = sumColumnRootSelect.qualify(predecessor);
SingleColumnSqlSelect qualifiedSumRootSelect = sumColumnRootSelect.qualify(predecessor);

List<Field<?>> partitioningFields = Stream.concat(
qualifiedIds.toFields().stream(),
Expand Down

0 comments on commit 9790ca6

Please sign in to comment.