Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion backend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Version Extractor
FROM alpine/git:2.52.0 AS version-extractor
FROM alpine/git:v2.52.0 AS version-extractor

WORKDIR /app
COPY .git .
Expand Down Expand Up @@ -37,14 +37,14 @@
RUN ln -s /usr/lib/libfontconfig.so.1 /usr/lib/libfontconfig.so && \
ln -s /lib/libuuid.so.1 /usr/lib/libuuid.so.1 && \
ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.musl-x86_64.so.1
ENV LD_LIBRARY_PATH /usr/lib

Check warning on line 40 in backend.Dockerfile

View workflow job for this annotation

GitHub Actions / backend

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 40 in backend.Dockerfile

View workflow job for this annotation

GitHub Actions / backend

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

WORKDIR /app
COPY --from=builder /app/executable/target/executable*jar ./conquery.jar

ENV CLUSTER_PORT=${CLUSTER_PORT:-8082}

Check warning on line 45 in backend.Dockerfile

View workflow job for this annotation

GitHub Actions / backend

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$CLUSTER_PORT' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 45 in backend.Dockerfile

View workflow job for this annotation

GitHub Actions / backend

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$CLUSTER_PORT' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
ENV ADMIN_PORT=${ADMIN_PORT:-8081}

Check warning on line 46 in backend.Dockerfile

View workflow job for this annotation

GitHub Actions / backend

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$ADMIN_PORT' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 46 in backend.Dockerfile

View workflow job for this annotation

GitHub Actions / backend

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$ADMIN_PORT' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
ENV API_PORT=${API_PORT:-8080}

Check warning on line 47 in backend.Dockerfile

View workflow job for this annotation

GitHub Actions / backend

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$API_PORT' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 47 in backend.Dockerfile

View workflow job for this annotation

GitHub Actions / backend

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$API_PORT' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

RUN mkdir /app/logs
VOLUME /app/logs
Expand Down
11 changes: 11 additions & 0 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@
<artifactId>testcontainers-postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-clickhouse</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-solr</artifactId>
Expand All @@ -383,6 +388,12 @@
<artifactId>ngdbc</artifactId>
<version>2.17.10</version>
</dependency>
<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.9.8</version>
<classifier>all</classifier>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_dropwizard</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

/**
Expand All @@ -38,6 +39,7 @@
@CPSType(id = "ARRAY_CONCEPT_QUERY", base = QueryDescription.class)
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE, onConstructor_ = {@JsonCreator})
@ToString
public class ArrayConceptQuery extends Query {

@NotEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.bakdata.conquery.models.query.resultinfo.printers.common.LocalizedEnumPrinter;
import com.bakdata.conquery.models.types.ResultType;
import com.bakdata.conquery.models.types.SemanticType;
import com.bakdata.conquery.sql.execution.ResultSetProcessor;
import lombok.experimental.UtilityClass;

@UtilityClass
Expand All @@ -27,6 +28,11 @@ public static ResultInfo datesInfo() {
public String userColumnName(PrintSettings printSettings) {
return C10nCache.getLocalized(ResultHeadersC10n.class, printSettings.getLocale()).dates();
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getDateRangeList;
}
};
}

Expand All @@ -39,6 +45,11 @@ public static ResultInfo historyDatesInfo() {
public String userColumnName(PrintSettings printSettings) {
return C10nCache.getLocalized(ResultHeadersC10n.class, printSettings.getLocale()).dates();
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getDateRangeList;
}
};
}

Expand All @@ -48,6 +59,11 @@ public static ResultInfo sourceInfo() {
public String userColumnName(PrintSettings printSettings) {
return C10nCache.getLocalized(ResultHeadersC10n.class, printSettings.getLocale()).source();
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getString;
}
};
}

Expand All @@ -58,6 +74,11 @@ public static ResultInfo formContextInfo() {
public String userColumnName(PrintSettings printSettings) {
return C10nCache.getLocalized(ResultHeadersC10n.class, printSettings.getLocale()).index();
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getInteger;
}
};
}

Expand All @@ -68,6 +89,11 @@ public static ResultInfo formDateRangeInfo() {
public String userColumnName(PrintSettings printSettings) {
return C10nCache.getLocalized(ResultHeadersC10n.class, printSettings.getLocale()).dateRange();
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getDateRange;
}
};
}

Expand All @@ -83,6 +109,11 @@ public Printer createPrinter(PrinterFactory printerFactory, PrintSettings printS
public String userColumnName(PrintSettings printSettings) {
return C10nCache.getLocalized(ResultHeadersC10n.class, printSettings.getLocale()).resolution();
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getString;
}
};
}

Expand All @@ -93,6 +124,11 @@ public static ResultInfo formEventDateInfo() {
public String userColumnName(PrintSettings printSettings) {
return C10nCache.getLocalized(ResultHeadersC10n.class, printSettings.getLocale()).eventDate();
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getDate;
}
};
}

Expand All @@ -108,6 +144,11 @@ public Printer createPrinter(PrinterFactory printerFactory, PrintSettings printS
public String userColumnName(PrintSettings printSettings) {
return C10nCache.getLocalized(ResultHeadersC10n.class, printSettings.getLocale()).observationScope();
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getString;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ public SqlFilters convertToSqlFilter(SqlIdColumns ids, ConversionContext context
FilterContext<VALUE> filterContext = FilterContext.forConceptConversion(ids, readValue(), context, tables);
final Filter<VALUE> resolve = (Filter<VALUE>) filter.resolve();
SqlFilters sqlFilters = resolve.createConverter().convertToSqlFilter(resolve, filterContext);
if (context.isNegation()) {
return new SqlFilters(sqlFilters.getSelects(), sqlFilters.getWhereClauses().negated());
}
return sqlFilters;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.bakdata.conquery.models.query.resultinfo.FixedLabelResultInfo;
import com.bakdata.conquery.models.query.resultinfo.ResultInfo;
import com.bakdata.conquery.models.types.ResultType;
import com.bakdata.conquery.sql.execution.ResultSetProcessor;
import com.bakdata.conquery.util.QueryUtils;
import com.fasterxml.jackson.annotation.JsonView;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -129,6 +130,11 @@ public String userColumnName(PrintSettings printSettings) {
public String defaultColumnName(PrintSettings printSettings) {
return defaultLabel(printSettings.getLocale());
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getBoolean;
}
});
}
return resultInfos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.bakdata.conquery.io.cps.CPSType;
import com.bakdata.conquery.io.jackson.View;
import com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId;
import com.bakdata.conquery.models.query.DateAggregationMode;
import com.bakdata.conquery.models.query.QueryPlanContext;
import com.bakdata.conquery.models.query.QueryResolveContext;
import com.bakdata.conquery.models.query.Visitable;
Expand Down Expand Up @@ -50,12 +51,12 @@ public void collectRequiredQueries(Set<ManagedExecutionId> requiredQueries) {
public void resolve(QueryResolveContext context) {
Preconditions.checkNotNull(context.getDateAggregationMode());

dateAction = determineDateAction(context);
dateAction = determineDateAction(context.getDateAggregationMode());
child.resolve(context);
}

private DateAggregationAction determineDateAction(QueryResolveContext context) {
return switch (context.getDateAggregationMode()) {
public static DateAggregationAction determineDateAction(DateAggregationMode dateAggregationMode) {
return switch (dateAggregationMode) {
case MERGE, NONE, INTERSECT -> DateAggregationAction.BLOCK;
case LOGICAL -> DateAggregationAction.NEGATE;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.bakdata.conquery.models.query.resultinfo.FixedLabelResultInfo;
import com.bakdata.conquery.models.query.resultinfo.ResultInfo;
import com.bakdata.conquery.models.types.ResultType;
import com.bakdata.conquery.sql.execution.ResultSetProcessor;
import com.bakdata.conquery.util.QueryUtils;
import com.fasterxml.jackson.annotation.JsonView;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -134,6 +135,11 @@ public String userColumnName(PrintSettings printSettings) {
public String defaultColumnName(PrintSettings printSettings) {
return defaultLabel(printSettings.getLocale());
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getBoolean;
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.bakdata.conquery.models.query.resultinfo.ResultInfo;
import com.bakdata.conquery.models.query.resultinfo.printers.common.ListResultInfo;
import com.bakdata.conquery.models.types.ResultType;
import com.bakdata.conquery.sql.execution.ResultSetProcessor;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Data;
import lombok.Setter;
Expand Down Expand Up @@ -188,6 +189,11 @@ public List<ResultInfo> getResultInfos() {
public String userColumnName(PrintSettings printSettings) {
return C10N.get(ResultHeadersC10n.class, printSettings.getLocale()).temporalCompareLabel(compare.userLabel(printSettings.getLocale()));
}

@Override
public ResultSetProcessor.Reader<?> createReader(ResultSetProcessor resultSetProcessor) {
return resultSetProcessor::getDateRangeList;
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public void toCSV(List<ResultInfo> idHeaders, List<ResultInfo> infos, Stream<Ent
createCSVBody(cfg, infos, resultStream, printSettings, StringResultPrinters.forCharset(charset));
}

private void createCSVBody(PrintSettings cfg, List<ResultInfo> infos, Stream<EntityResult> results, PrintSettings printSettings,
PrinterFactory printerFactory) {
private void createCSVBody(
PrintSettings cfg, List<ResultInfo> infos, Stream<EntityResult> results, PrintSettings printSettings,
PrinterFactory printerFactory) {
final Printer[] printers = infos.stream().map(info -> info.createPrinter(printerFactory, printSettings)).toArray(Printer[]::new);

results.map(result -> Pair.of(cfg.getIdMapper().map(result), result))
Expand All @@ -52,20 +53,19 @@ private void createCSVBody(PrintSettings cfg, List<ResultInfo> infos, Stream<Ent
public void printLine(EntityPrintId entity, Printer[] printers, Object[] values) {
// Cast here to Object[] so it is clear to intellij that the varargs call is intended
writer.addValues((Object[]) entity.getExternalId());
try {
for (int i = 0; i < printers.length; i++) {
final Object value = values[i];

if (value == null) {
writer.addValue("");
continue;
}
for (int i = 0; i < printers.length; i++) {
final Object value = values[i];

if (value == null) {
writer.addValue("");
continue;
}
try {
writer.addValue(printers[i].apply(value));
}
}
catch (Exception e) {
throw new IllegalStateException("Unable to print line " + Arrays.deepToString(values), e);
catch (Exception e) {
throw new IllegalStateException("Failed to print column %s of line %s".formatted(i, Arrays.deepToString(values)), e);
}
}

writer.writeValuesToRow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.bakdata.conquery.sql.conversion.SqlConverter;
import com.bakdata.conquery.sql.conversion.dialect.DialectBundle;
import com.bakdata.conquery.sql.execution.ResultSetProcessor;
import com.bakdata.conquery.sql.execution.ResultSetProcessorFactory;
import com.bakdata.conquery.sql.execution.SqlExecutionService;
import io.dropwizard.core.setup.Environment;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -46,7 +45,7 @@ public LocalNamespace createNamespace(
DSLContext dslContext = connection.connect();
DialectBundle dialectBundle = connection.getConnection().getDialect().getDialectBundle();

ResultSetProcessor resultSetProcessor = ResultSetProcessorFactory.create(config, dialectBundle);
ResultSetProcessor resultSetProcessor = dialectBundle.getResultSetProcessor(config);
SqlExecutionService sqlExecutionService = new SqlExecutionService(dslContext, resultSetProcessor);

NodeConversions nodeConversions = new NodeConversions(config.getIdColumns(), dialectBundle, dslContext, sqlExecutionService, clock);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package com.bakdata.conquery.mode.local;

import static com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil.collectExtraData;
import static com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil.readDates;
import static com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil.verifyOnlySingles;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.name;
import static org.jooq.impl.DSL.table;
import static org.jooq.impl.DSL.val;
import static org.jooq.impl.DSL.when;
import static com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil.*;
import static org.jooq.impl.DSL.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import jakarta.validation.constraints.NotEmpty;

import com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolver;
import com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil;
Expand All @@ -27,7 +22,6 @@
import com.bakdata.conquery.sql.execution.SqlExecutionService;
import com.bakdata.conquery.util.DateReader;
import com.bakdata.conquery.util.io.IdColumnUtil;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import org.jooq.CommonTableExpression;
import org.jooq.DSLContext;
Expand All @@ -39,14 +33,14 @@
import org.jooq.Select;
import org.jooq.SelectConditionStep;
import org.jooq.Table;
import org.jooq.impl.DSL;

@RequiredArgsConstructor
public class SqlEntityResolver implements EntityResolver {

public static final String ROW_INDEX = "rowIndex";
private static final Name IS_RESOLVED_ALIAS = name("is_resolved");
private static final Name UNRESOLVED_CTE = name("ids_unresolved");
public static final String ROW_INDEX = "rowIndex";

private final IdColumnConfig idColumns;
private final DSLContext context;
private final DialectBundle dialect;
Expand Down Expand Up @@ -151,11 +145,11 @@ private Map<Integer, IdResolveInfo> resolveIds(String[][] values, List<Function<
Field<Integer> rowIndex = field(name(ROW_INDEX), Integer.class);
Field<String> externalPrimaryColumn = field(name(SharedAliases.PRIMARY_COLUMN.getAlias()), String.class);
Field<String> innerPrimaryColumn = field(name(idColumns.findPrimaryIdColumn().getField()), String.class);
Field<Boolean> isResolved = when(innerPrimaryColumn.isNotNull(), val(true))
.otherwise(false)
.as(IS_RESOLVED_ALIAS);
// Would prefer this to be `is not null`, but hana does not support that for fields
Field<Boolean> isResolved = case_().when(innerPrimaryColumn.isNull(), inline(false)).otherwise(inline(true)).as(IS_RESOLVED_ALIAS);

Table<Record> allIdsTable = table(name(idColumns.getTable()));

SelectConditionStep<Record3<Integer, String, Boolean>> resolveIdsQuery =
context.with(unresolvedCte)
.select(rowIndex, externalPrimaryColumn, isResolved)
Expand Down Expand Up @@ -187,8 +181,8 @@ private CommonTableExpression<?> createUnresolvedCte(String[][] values, List<Fun
continue;
}

Field<Integer> rowIndex = val(i).as(ROW_INDEX);
Field<String> externalPrimaryColumn = val(resolvedId).as(SharedAliases.PRIMARY_COLUMN.getAlias());
Field<Integer> rowIndex = inline(i).as(ROW_INDEX);
Field<String> externalPrimaryColumn = inline(resolvedId).as(SharedAliases.PRIMARY_COLUMN.getAlias());
Select<Record2<Integer, String>> externalIdSelect = context.select(rowIndex, externalPrimaryColumn)
// some dialects can't just select static values without FROM clause
.from(dialect.getFunctionProvider().getNoOpTable());
Expand Down
Loading
Loading