New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit tests for SqlServer #503
Add unit tests for SqlServer #503
Conversation
This is first attempt to use docker image in unit tests. Things to improve:
|
domain = pushDownDomain(client, session, column, domain); | ||
builder.add(toPredicate(column.getColumnName(), domain, column, accumulator)); | ||
} | ||
} | ||
return builder.build(); | ||
} | ||
|
||
protected boolean isAcceptedDomain(Domain domain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert, this is a responsibility of pushDownDomain
.
@@ -266,8 +266,8 @@ private String toPredicate(String columnName, String operator, Object value, Jdb | |||
|
|||
private String quote(String name) | |||
{ | |||
name = name.replace(quote, quote + quote); | |||
return quote + name + quote; | |||
name = name.replace(identifierQoute, identifierQoute + identifierQoute); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline
public class SqlServerQueryBuilder | ||
extends QueryBuilder | ||
{ | ||
// SqlServer supports 2100 parameters in preparared statement, 100 is left for other parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we would support queries with 1 large IN
but not queries with 2 IN
s?
public PreparedStatement buildSql(ConnectorSession session, Connection connection, JdbcSplit split, List<JdbcColumnHandle> columnHandles) | ||
throws SQLException | ||
{ | ||
return new SqlServerQueryBuilder().buildSql( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the identifierQuote
selection logic is in 2 places:
SqlServerQueryBuilder::new
SqlServerClient::new
IMO it would be better to pass this.identifierQuote
to the QueryBuilder constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Let's solve it separate PR.
presto-testing-docker/src/main/java/io/prestosql/testing/TemporaryDockerContainer.java
Outdated
Show resolved
Hide resolved
throws Exception | ||
{ | ||
this.dockerContainer = new TemporaryDockerContainer( | ||
"microsoft/mssql-server-linux:2017-CU6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the version we're using in product tests.
|
||
RetryPolicy<Object> retryPolicy = new RetryPolicy<>() | ||
.withMaxDuration(Duration.of(5, MINUTES)) | ||
.withMaxAttempts(Integer.MAX_VALUE) // limited by MaxDuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the default if you don't set this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3
RetryPolicy<Object> retryPolicy = new RetryPolicy<>() | ||
.withMaxDuration(Duration.of(5, MINUTES)) | ||
.withMaxAttempts(Integer.MAX_VALUE) // limited by MaxDuration | ||
.onRetry(event -> LOG.info("Waiting for sql-server...")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"SQL Server" ?
presto-sqlserver/pom.xml
Outdated
</dependency> | ||
<dependency> | ||
<groupId>io.prestosql</groupId> | ||
<artifactId>presto-tests</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this up, eg after presto-main
f4ab75e
to
827328c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findepi Comments addressed.
public PreparedStatement buildSql(ConnectorSession session, Connection connection, JdbcSplit split, List<JdbcColumnHandle> columnHandles) | ||
throws SQLException | ||
{ | ||
return new SqlServerQueryBuilder().buildSql( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Let's solve it separate PR.
|
||
RetryPolicy<Object> retryPolicy = new RetryPolicy<>() | ||
.withMaxDuration(Duration.of(5, MINUTES)) | ||
.withMaxAttempts(Integer.MAX_VALUE) // limited by MaxDuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3
} | ||
|
||
@Test | ||
public void testDropTable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me fix this in separate PR. Add this AbstractTestIntegrationSmokeTest
could blow up.
@Test | ||
public void testInsert() | ||
{ | ||
executeInSqlServer("CREATE TABLE test_insert (x bigint, y varchar(100))"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you CREATE TABLE in Presto?
Because test is focused on INSERT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments about TemporaryDockerContainer
This is really nice!
|
||
public class SqlServerClient | ||
extends BaseJdbcClient | ||
{ | ||
private static final Joiner DOT_JOINER = Joiner.on("."); | ||
|
||
private static final Map<Type, WriteMapping> WRITE_MAPPINGS = ImmutableMap.<Type, WriteMapping>builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does sql server have all the types used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know. There is no logical change here. I don't want to fix mapping in SqlServer now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so. So let's not inline this from basejdbc.
Instead, you can call super and then add DISABLE_UNSUPPORTED_PUSHDOWN. This is a hack, but at least it does not pretend it is not a hack. You then can adorn the code with // TODO implement explicit type mappings
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was first idea. However, after our offline discussion I understood that you prefer inlinining. Maybe, it was because I promised you that I will handle mapping end-to-end. I would like to, but I don't have time right now for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for mis-communication.
Ideally we should inline & retain only the necessary bits. And add TypeMapping test.
I am aware you might not have the cycles to reach this ideal, so I would really prefer no inlining at all.
int columnSize = type.getColumnSize(); | ||
switch (type.getJdbcType()) { | ||
case Types.BIT: | ||
case Types.BOOLEAN: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does sql server have bit data type? And boolean?
Same for all the mappings.
return decimalColumnMapping(decimalType, UnaryOperator.identity()); | ||
} | ||
|
||
public static ColumnMapping decimalColumnMapping(DecimalType decimalType, UnaryOperator<Domain> pushDownConverter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: pushDownConverter → pushdownConverter
However, i think this is a wrong abstraction level.
Why do you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this to avoid inlining more code into SqlServer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see 45e0c2f#r268709657. Then you should be able to revert this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to revert changes in StandardColumnMappings.java
now?
they are in Fix large IN queries agains SqlServer
cmt, but look no longer needed here.
presto-sqlserver/src/main/java/io/prestosql/plugin/sqlserver/SqlServerClient.java
Outdated
Show resolved
Hide resolved
presto-sqlserver/src/main/java/io/prestosql/plugin/sqlserver/SqlServerClient.java
Show resolved
Hide resolved
|
||
private int extractPort(Map.Entry<String, List<PortBinding>> entry) | ||
{ | ||
return Integer.parseInt(entry.getKey().replace("/tcp", "").replace("/udp", "")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, Docker for Mac does not handle UDP correctly, so let's not pretend this is supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when eg 88/tcp and 88/udp are bound but mapped to a different host port?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed UDP support
.collect(toImmutableMap( | ||
entry -> extractPort(entry), | ||
entry -> entry.getValue().stream() | ||
.filter(portBinding -> portBinding.hostIp().equals(hostIp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can there by anything else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think so.
.map(PortBinding::hostPort) | ||
.collect(toOptional()) | ||
.map(Integer::parseInt) | ||
.orElseThrow(() -> new IllegalStateException("Could not find port mapping for: " + entry.getKey())))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Could not extract port mapping from " + entry
} | ||
|
||
@Override | ||
public void close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it as the last instance method
LOG.info("Auto-assigned host ports are %s", hostPorts); | ||
} | ||
|
||
public int getHostPort(int port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move it below calculateHostPorts
presto-sqlserver/src/test/java/io/prestosql/plugin/sqlserver/TestingSqlServerServer.java
Outdated
Show resolved
Hide resolved
public static final String PASSWORD = "SQLServerPass1"; | ||
|
||
private static TemporaryDockerContainer dockerContainer = new TemporaryDockerContainer( | ||
"microsoft/mssql-server-linux:2017-CU6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outdated version
|
||
private static TemporaryDockerContainer dockerContainer = new TemporaryDockerContainer( | ||
"microsoft/mssql-server-linux:2017-CU6", | ||
"sqlserver-master", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just sqlserver
{ | ||
TestingSqlServerServer.waitForSqlServer(); | ||
|
||
DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is deprecated (😞)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe simply undeprecate this?
} | ||
} | ||
|
||
private static synchronized void provisionTables(Session session, QueryRunner queryRunner, Iterable<TpchTable<?>> tables) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure this is no longer static synchronized
when you move container init to be once-per-test-class.
} | ||
|
||
@Test | ||
public void testDropTable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine, so don't add them here.
|
||
private AutoCloseable withTable(String tableName, String tableDefinition) | ||
{ | ||
executeInSqlServer(format("CREATE TABLE %s%s", tableName, tableDefinition)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"CREATE TABLE %s %s"
would be slightly more readable
@@ -110,6 +110,7 @@ | |||
<module>presto-geospatial</module> | |||
<module>presto-geospatial-toolkit</module> | |||
<module>presto-benchmark</module> | |||
<module>presto-testing-docker</module> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a new module for this? Can't we put it in presto-tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do. Otherwise it fails due conflict of classes and native libs with cassandra. I tried to solve this, but shading native libraries is not an easy thing to do.
827328c
to
263d4b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed comments as fixups
|
||
public class SqlServerClient | ||
extends BaseJdbcClient | ||
{ | ||
private static final Joiner DOT_JOINER = Joiner.on("."); | ||
|
||
private static final Map<Type, WriteMapping> WRITE_MAPPINGS = ImmutableMap.<Type, WriteMapping>builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know. There is no logical change here. I don't want to fix mapping in SqlServer now.
return decimalColumnMapping(decimalType, UnaryOperator.identity()); | ||
} | ||
|
||
public static ColumnMapping decimalColumnMapping(DecimalType decimalType, UnaryOperator<Domain> pushDownConverter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this to avoid inlining more code into SqlServer.
presto-sqlserver/src/main/java/io/prestosql/plugin/sqlserver/SqlServerClient.java
Outdated
Show resolved
Hide resolved
@@ -110,6 +110,7 @@ | |||
<module>presto-geospatial</module> | |||
<module>presto-geospatial-toolkit</module> | |||
<module>presto-benchmark</module> | |||
<module>presto-testing-docker</module> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do. Otherwise it fails due conflict of classes and native libs with cassandra. I tried to solve this, but shading native libraries is not an easy thing to do.
public TemporaryDockerContainer(String image, String hostName, List<Integer> ports, Map<String, String> environment) | ||
{ | ||
this.image = requireNonNull(image, "image is null"); | ||
this.hostName = requireNonNull(hostName, "hostName is null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used internally, I can remove it from here for now.
.withMaxDuration(Duration.of(5, MINUTES)) | ||
.withMaxAttempts(Integer.MAX_VALUE) // limited by MaxDuration | ||
.onRetry(event -> LOG.info(format("Waiting for %s...", hostName))) | ||
.withDelay(Duration.of(5, SECONDS)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis does not complain for such things. It would complain if I would raise it above 10 minutes. Anyway, I changed this to 10s.
|
||
ports.forEach(port -> { | ||
RetryPolicy<Object> retryPolicy = new RetryPolicy<>() | ||
.withMaxDuration(Duration.of(5, MINUTES)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing this the same value is used twice, does not mean it is the same timeout. For me waiting on container or a service in it is a bit different.
.collect(toImmutableMap( | ||
entry -> extractPort(entry), | ||
entry -> entry.getValue().stream() | ||
.filter(portBinding -> portBinding.hostIp().equals(hostIp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think so.
|
||
private int extractPort(Map.Entry<String, List<PortBinding>> entry) | ||
{ | ||
return Integer.parseInt(entry.getKey().replace("/tcp", "").replace("/udp", "")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed UDP support
dockerClient = null; | ||
} | ||
|
||
protected boolean isDebug() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used to be more complicated. It was checking environment variables.
|
||
public class SqlServerClient | ||
extends BaseJdbcClient | ||
{ | ||
private static final Joiner DOT_JOINER = Joiner.on("."); | ||
|
||
private static final Map<Type, WriteMapping> WRITE_MAPPINGS = ImmutableMap.<Type, WriteMapping>builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so. So let's not inline this from basejdbc.
Instead, you can call super and then add DISABLE_UNSUPPORTED_PUSHDOWN. This is a hack, but at least it does not pretend it is not a hack. You then can adorn the code with // TODO implement explicit type mappings
.
return decimalColumnMapping(decimalType, UnaryOperator.identity()); | ||
} | ||
|
||
public static ColumnMapping decimalColumnMapping(DecimalType decimalType, UnaryOperator<Domain> pushDownConverter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see 45e0c2f#r268709657. Then you should be able to revert this change.
implements Closeable | ||
{ | ||
|
||
private static final boolean DEBUG = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put after logger (logger should be the first)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't know why logger is that important in every class. For me it should be defined at the bottom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, i know some folks want to put weird things at the bottom. Like private Ctor() {}
.
However, it's not about importance. It's just a convention -- i am used to look at the top to see wether a logger is already defined. Or "utility class constructor".
private Map<Integer, Integer> hostPorts; | ||
|
||
public TemporaryDockerContainer(String image, String hostName, List<Integer> ports, Map<String, String> environment) | ||
public TemporaryDockerContainer(String image, List<Integer> ports, Map<String, String> environment, CheckedConsumer<HostPortProvider> verifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verifier -> healthCheck ?
Failsafe.with(retryPolicy).run(() -> verifier.accept(this::getHostPort)); | ||
} | ||
|
||
private boolean isContainerUp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it before waitForContainer
since it's called earlier
same for createContainer
*/ | ||
package io.prestosql.testing; | ||
|
||
public interface HostPortProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can define this as an inner class in TemporaryDockerContainer
.
@@ -24,112 +24,119 @@ | |||
import io.airlift.log.Logger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change package name to io.prestosql.testing.docker
-- presto-testing-docker
module should have its own "namespace"
{ | ||
TestingSqlServerServer.waitForSqlServer(); | ||
|
||
DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe simply undeprecate this?
{ | ||
return format("jdbc:sqlserver://localhost:%s", dockerContainer.getHostPort(1433)); | ||
this.dockerContainer = new TemporaryDockerContainer( | ||
"microsoft/mssql-server-linux:2017-CU6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public TemporaryDockerContainer(String image, String hostName, List<Integer> ports, Map<String, String> environment) | ||
{ | ||
this.image = requireNonNull(image, "image is null"); | ||
this.hostName = requireNonNull(hostName, "hostName is null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is needed internally, then i'm OK
(i am aware you removed this... so up to you)
263d4b3
to
1016708
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments addressed
|
||
public class SqlServerClient | ||
extends BaseJdbcClient | ||
{ | ||
private static final Joiner DOT_JOINER = Joiner.on("."); | ||
|
||
private static final Map<Type, WriteMapping> WRITE_MAPPINGS = ImmutableMap.<Type, WriteMapping>builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was first idea. However, after our offline discussion I understood that you prefer inlinining. Maybe, it was because I promised you that I will handle mapping end-to-end. I would like to, but I don't have time right now for this.
implements Closeable | ||
{ | ||
|
||
private static final boolean DEBUG = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't know why logger is that important in every class. For me it should be defined at the bottom.
} | ||
|
||
@Test | ||
public void testDropTable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? It is better to have test for single connector vs for none.
@Test | ||
public void testInsert() | ||
{ | ||
executeInSqlServer("CREATE TABLE test_insert (x bigint, y varchar(100))"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will move it to AbstractTestIntegrationSmokeTest
in separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
@@ -81,7 +81,11 @@ public static ColumnMapping blockMapping(Type prestoType, BlockReadFunction read | |||
private final WriteFunction writeFunction; | |||
private final UnaryOperator<Domain> pushdownConverter; | |||
|
|||
private ColumnMapping(Type type, ReadFunction readFunction, WriteFunction writeFunction, UnaryOperator<Domain> pushdownConverter) | |||
/** | |||
* Prefer factory methods instead over calling constructor directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deprecated Prefer factory methods ...
@@ -37,6 +43,17 @@ | |||
{ | |||
private static final Joiner DOT_JOINER = Joiner.on("."); | |||
|
|||
// SqlServer supports 2100 parameters in prepared statement, let's create a space for for about 4 big IN predicates | |||
static final int SQL_SERVER_MAX_LIST_EXPRESSIONS = 500; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
or @VisibleForTesting
|
||
import javax.inject.Inject; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.util.Optional; | ||
import java.util.function.UnaryOperator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix large IN queries agains SqlServer
typo in cmt msg: "against"
@@ -37,6 +43,17 @@ | |||
{ | |||
private static final Joiner DOT_JOINER = Joiner.on("."); | |||
|
|||
// SqlServer supports 2100 parameters in prepared statement, let's create a space for for about 4 big IN predicates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"for for"
return decimalColumnMapping(decimalType, UnaryOperator.identity()); | ||
} | ||
|
||
public static ColumnMapping decimalColumnMapping(DecimalType decimalType, UnaryOperator<Domain> pushDownConverter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to revert changes in StandardColumnMappings.java
now?
they are in Fix large IN queries agains SqlServer
cmt, but look no longer needed here.
import static java.time.temporal.ChronoUnit.SECONDS; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
public final class DockerContainer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the rename.
now the cmt msg Introduce TemporaryDockerContainer
can be changed to Introduce DockerContainer for testing
or sth like that.
createContainer(ports); | ||
} | ||
|
||
checkState(isContainerUp(), "Container was not started properly"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this fails, will the container be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Tested manually.
|
||
LOG.info("Auto-assigned host ports are %s", hostPorts); | ||
|
||
waitForContainer(healthCheck); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this fails, will the container be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Thanks for asking. It appeared that when method throws in abortOn
then failsafe
continue to retry. I fixed that.
|
||
private static void execute(HostPortProvider hostPortProvider, String sql) | ||
{ | ||
try (Connection conn = DriverManager.getConnection(getJdbcUrl(hostPortProvider.getHostPort(SQL_SERVER_PORT)), USER, PASSWORD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extract getJdbcUrl(hostPortProvider.getHostPort(SQL_SERVER_PORT))
as a variable?
This way it is consistent with BaseJdbcClient
DockerContainer is an utility to make it easier to use external services managed provided with docker images for unit testing.
1016708
to
ca154eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments addressed Thanks for reviewing.
createContainer(ports); | ||
} | ||
|
||
checkState(isContainerUp(), "Container was not started properly"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Tested manually.
|
||
LOG.info("Auto-assigned host ports are %s", hostPorts); | ||
|
||
waitForContainer(healthCheck); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Thanks for asking. It appeared that when method throws in abortOn
then failsafe
continue to retry. I fixed that.
Add unit tests for SqlServer