diff --git a/backend/src/main/java/com/bakdata/conquery/mode/local/LocalNamespaceHandler.java b/backend/src/main/java/com/bakdata/conquery/mode/local/LocalNamespaceHandler.java index b437423e30..52a389c5fe 100644 --- a/backend/src/main/java/com/bakdata/conquery/mode/local/LocalNamespaceHandler.java +++ b/backend/src/main/java/com/bakdata/conquery/mode/local/LocalNamespaceHandler.java @@ -20,6 +20,7 @@ import com.bakdata.conquery.sql.conversion.SqlConverter; import com.bakdata.conquery.sql.conversion.dialect.SqlDialect; import com.bakdata.conquery.sql.conversion.dialect.SqlDialectFactory; +import com.bakdata.conquery.sql.execution.ResultSetProcessor; import com.bakdata.conquery.sql.execution.ResultSetProcessorFactory; import com.bakdata.conquery.sql.execution.SqlExecutionResult; import com.bakdata.conquery.sql.execution.SqlExecutionService; @@ -48,7 +49,8 @@ public LocalNamespace createNamespace(NamespaceStorage namespaceStorage, MetaSto DSLContext dslContext = dslContextWrapper.getDslContext(); SqlDialect sqlDialect = dialectFactory.createSqlDialect(databaseConfig.getDialect()); - SqlExecutionService sqlExecutionService = new SqlExecutionService(dslContext, ResultSetProcessorFactory.create(sqlDialect)); + ResultSetProcessor resultSetProcessor = ResultSetProcessorFactory.create(config, sqlDialect); + SqlExecutionService sqlExecutionService = new SqlExecutionService(dslContext, resultSetProcessor); NodeConversions nodeConversions = new NodeConversions(idColumns, sqlDialect, dslContext, databaseConfig, sqlExecutionService); SqlConverter sqlConverter = new SqlConverter(nodeConversions); ExecutionManager executionManager = new SqlExecutionManager(sqlConverter, sqlExecutionService, metaStorage); diff --git a/backend/src/main/java/com/bakdata/conquery/sql/execution/DefaultResultSetProcessor.java b/backend/src/main/java/com/bakdata/conquery/sql/execution/DefaultResultSetProcessor.java index 415087b74b..f14fc852b9 100644 --- a/backend/src/main/java/com/bakdata/conquery/sql/execution/DefaultResultSetProcessor.java +++ b/backend/src/main/java/com/bakdata/conquery/sql/execution/DefaultResultSetProcessor.java @@ -2,7 +2,6 @@ import java.math.BigDecimal; import java.math.RoundingMode; -import java.sql.Date; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; @@ -10,11 +9,14 @@ import java.util.function.Function; import java.util.function.Predicate; +import com.bakdata.conquery.models.config.ConqueryConfig; +import com.bakdata.conquery.util.DateReader; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor class DefaultResultSetProcessor implements ResultSetProcessor { + private final ConqueryConfig config; private final SqlCDateSetParser sqlCDateSetParser; @Override @@ -48,11 +50,12 @@ public Boolean getBoolean(ResultSet resultSet, int columnIndex) throws SQLExcept @Override public Number getDate(ResultSet resultSet, int columnIndex) throws SQLException { - Date date = resultSet.getDate(columnIndex); - if (date == null) { + String dateString = resultSet.getString(columnIndex); + if (dateString == null) { return null; } - return date.toLocalDate().toEpochDay(); + DateReader dateReader = config.getLocale().getDateReader(); + return dateReader.parseToLocalDate(dateString).toEpochDay(); } @Override @@ -97,7 +100,11 @@ public List getMoneyList(ResultSet resultSet, int columnIndex) throw @Override public List getDateList(ResultSet resultSet, int columnIndex) throws SQLException { - return fromString(resultSet, columnIndex, (string) -> Date.valueOf(string).toLocalDate().toEpochDay()); + return fromString(resultSet, columnIndex, this::parseWithDateReader); + } + + private Number parseWithDateReader(String string) { + return config.getLocale().getDateReader().parseToLocalDate(string).toEpochDay(); } private List fromString(ResultSet resultSet, int columnIndex, Function parseFunction) throws SQLException { diff --git a/backend/src/main/java/com/bakdata/conquery/sql/execution/ResultSetProcessorFactory.java b/backend/src/main/java/com/bakdata/conquery/sql/execution/ResultSetProcessorFactory.java index 1ab5e99be0..a9165b1ba1 100644 --- a/backend/src/main/java/com/bakdata/conquery/sql/execution/ResultSetProcessorFactory.java +++ b/backend/src/main/java/com/bakdata/conquery/sql/execution/ResultSetProcessorFactory.java @@ -1,11 +1,12 @@ package com.bakdata.conquery.sql.execution; +import com.bakdata.conquery.models.config.ConqueryConfig; import com.bakdata.conquery.sql.conversion.dialect.SqlDialect; public class ResultSetProcessorFactory { - public static ResultSetProcessor create(SqlDialect sqlDialect) { - return new DefaultResultSetProcessor(sqlDialect.getCDateSetParser()); + public static ResultSetProcessor create(ConqueryConfig config, SqlDialect sqlDialect) { + return new DefaultResultSetProcessor(config, sqlDialect.getCDateSetParser()); } } diff --git a/backend/src/test/java/com/bakdata/conquery/integration/sql/dialect/PostgreSqlIntegrationTests.java b/backend/src/test/java/com/bakdata/conquery/integration/sql/dialect/PostgreSqlIntegrationTests.java index 3a31b73d7c..019e1cb5f7 100644 --- a/backend/src/test/java/com/bakdata/conquery/integration/sql/dialect/PostgreSqlIntegrationTests.java +++ b/backend/src/test/java/com/bakdata/conquery/integration/sql/dialect/PostgreSqlIntegrationTests.java @@ -17,6 +17,7 @@ import com.bakdata.conquery.sql.conversion.dialect.PostgreSqlDialect; import com.bakdata.conquery.sql.conversion.model.SqlQuery; import com.bakdata.conquery.sql.conversion.supplier.DateNowSupplier; +import com.bakdata.conquery.sql.execution.ResultSetProcessor; import com.bakdata.conquery.sql.execution.ResultSetProcessorFactory; import com.bakdata.conquery.sql.execution.SqlExecutionService; import lombok.Getter; @@ -84,7 +85,8 @@ static void after() throws IOException { public void shouldThrowException() { // This can be removed as soon as we switch to a full integration test including the REST API I18n.init(); - SqlExecutionService executionService = new SqlExecutionService(dslContextWrapper.getDslContext(), ResultSetProcessorFactory.create(testSqlDialect)); + ResultSetProcessor resultSetProcessor = ResultSetProcessorFactory.create(config, testSqlDialect); + SqlExecutionService executionService = new SqlExecutionService(dslContextWrapper.getDslContext(), resultSetProcessor); SqlQuery validQuery = new TestSqlQuery("SELECT 1"); Assertions.assertThatNoException().isThrownBy(() -> executionService.execute(validQuery));