Skip to content

Commit dab5466

Browse files
committed
SQL: Remove the last remaining server dependencies from jdbc (#30771)
Removes the last remaining server dependencies from jdbc client. In order to do that it introduces the new project sql-shared-proto that contains only XContent-serializable classes. HTTP Client and JDBC now depend only on sql-shared-proto. I had to keep the original sql-proto project since it is used as a dependency by sql-cli and security integration tests. Relates #29856
1 parent abbb427 commit dab5466

File tree

32 files changed

+489
-750
lines changed

32 files changed

+489
-750
lines changed

x-pack/plugin/sql/jdbc/build.gradle

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,20 @@ dependencies {
5252
compile (xpackProject('plugin:sql:sql-shared-client')) {
5353
transitive = false
5454
}
55-
compile (xpackProject('plugin:sql:sql-proto')) {
55+
compile (xpackProject('plugin:sql:sql-shared-proto')) {
5656
transitive = false
5757
}
5858
} else {
5959
bundled (xpackProject('plugin:sql:sql-shared-client')) {
6060
transitive = false
6161
}
62-
bundled (xpackProject('plugin:sql:sql-proto')) {
62+
bundled (xpackProject('plugin:sql:sql-shared-proto')) {
6363
transitive = false
6464
}
6565
}
66-
compile (project(':server')) {
67-
transitive = false
68-
}
6966
compile (project(':libs:x-content')) {
7067
transitive = false
7168
}
72-
compile "org.apache.lucene:lucene-core:${versions.lucene}"
7369
compile 'joda-time:joda-time:2.9.9'
7470
compile project(':libs:elasticsearch-core')
7571
runtime "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
@@ -80,15 +76,13 @@ dependencies {
8076
}
8177

8278
dependencyLicenses {
83-
mapping from: /sql-proto.*/, to: 'elasticsearch'
79+
mapping from: /sql-shared-proto.*/, to: 'elasticsearch'
8480
mapping from: /sql-shared-client.*/, to: 'elasticsearch'
8581
mapping from: /jackson-.*/, to: 'jackson'
86-
mapping from: /lucene-.*/, to: 'lucene'
8782
mapping from: /elasticsearch-core.*/, to: 'elasticsearch'
88-
ignoreSha 'sql-proto'
83+
ignoreSha 'sql-shared-proto'
8984
ignoreSha 'sql-shared-client'
9085
ignoreSha 'elasticsearch'
91-
ignoreSha 'elasticsearch-core'
9286
}
9387

9488
/*

x-pack/plugin/sql/jdbc/licenses/lucene-LICENSE.txt

Lines changed: 0 additions & 475 deletions
This file was deleted.

x-pack/plugin/sql/jdbc/licenses/lucene-NOTICE.txt

Lines changed: 0 additions & 192 deletions
This file was deleted.

x-pack/plugin/sql/jdbc/licenses/lucene-core-7.4.0-snapshot-59f2b7aec2.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/jdbc/TypeConverterTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
import org.elasticsearch.common.xcontent.XContentHelper;
1111
import org.elasticsearch.common.xcontent.json.JsonXContent;
1212
import org.elasticsearch.test.ESTestCase;
13-
import org.elasticsearch.xpack.sql.plugin.SqlQueryResponse;
14-
import org.elasticsearch.xpack.sql.proto.Mode;
1513
import org.joda.time.DateTime;
14+
import org.joda.time.ReadableDateTime;
1615

1716
import java.sql.JDBCType;
1817

@@ -51,7 +50,11 @@ private Object convertAsNative(Object value, JDBCType type) throws Exception {
5150
XContentBuilder builder = JsonXContent.contentBuilder();
5251
builder.startObject();
5352
builder.field("value");
54-
SqlQueryResponse.value(builder, Mode.JDBC, value);
53+
if (value instanceof ReadableDateTime) {
54+
builder.value(((ReadableDateTime) value).getMillis());
55+
} else {
56+
builder.value(value);
57+
}
5558
builder.endObject();
5659
builder.close();
5760
Object copy = XContentHelper.convertToMap(BytesReference.bytes(builder), false, builder.contentType()).v2().get("value");

x-pack/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/CliSession.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.elasticsearch.xpack.sql.client.HttpClient;
99
import org.elasticsearch.xpack.sql.client.shared.ClientException;
1010
import org.elasticsearch.xpack.sql.client.shared.Version;
11-
import org.elasticsearch.xpack.sql.plugin.AbstractSqlQueryRequest;
1211
import org.elasticsearch.xpack.sql.proto.MainResponse;
1312
import org.elasticsearch.xpack.sql.proto.Protocol;
1413

x-pack/plugin/sql/sql-cli/src/test/java/org/elasticsearch/xpack/sql/cli/CliSessionTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class CliSessionTests extends ESTestCase {
2828
public void testProperConnection() throws Exception {
2929
HttpClient httpClient = mock(HttpClient.class);
3030
when(httpClient.serverInfo()).thenReturn(new MainResponse(randomAlphaOfLength(5), org.elasticsearch.Version.CURRENT.toString(),
31-
ClusterName.DEFAULT.value(), UUIDs.randomBase64UUID(), Build.CURRENT));
31+
ClusterName.DEFAULT.value(), UUIDs.randomBase64UUID()));
3232
CliSession cliSession = new CliSession(httpClient);
3333
cliSession.checkConnection();
3434
verify(httpClient, times(1)).serverInfo();
@@ -58,7 +58,7 @@ public void testWrongServerVersion() throws Exception {
5858
}
5959
when(httpClient.serverInfo()).thenReturn(new MainResponse(randomAlphaOfLength(5),
6060
org.elasticsearch.Version.fromString(major + "." + minor + ".23").toString(),
61-
ClusterName.DEFAULT.value(), UUIDs.randomBase64UUID(), Build.CURRENT));
61+
ClusterName.DEFAULT.value(), UUIDs.randomBase64UUID()));
6262
CliSession cliSession = new CliSession(httpClient);
6363
expectThrows(ClientException.class, cliSession::checkConnection);
6464
verify(httpClient, times(1)).serverInfo();

x-pack/plugin/sql/sql-cli/src/test/java/org/elasticsearch/xpack/sql/cli/command/ServerInfoCliCommandTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void testShowInfo() throws Exception {
3636
HttpClient client = mock(HttpClient.class);
3737
CliSession cliSession = new CliSession(client);
3838
when(client.serverInfo()).thenReturn(new MainResponse("my_node", "1.2.3",
39-
new ClusterName("my_cluster").value(), UUIDs.randomBase64UUID(), Build.CURRENT));
39+
new ClusterName("my_cluster").value(), UUIDs.randomBase64UUID()));
4040
ServerInfoCliCommand cliCommand = new ServerInfoCliCommand();
4141
assertTrue(cliCommand.handle(testTerminal, cliSession, "info"));
4242
assertEquals(testTerminal.toString(), "Node:<em>my_node</em> Cluster:<em>my_cluster</em> Version:<em>1.2.3</em>\n");

x-pack/plugin/sql/sql-proto/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies {
2424
compile (project(':libs:x-content')) {
2525
transitive = false
2626
}
27+
compile xpackProject('plugin:sql:sql-shared-proto')
2728
compile "org.apache.lucene:lucene-core:${versions.lucene}"
2829
compile 'joda-time:joda-time:2.9.9'
2930
runtime "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"

x-pack/plugin/sql/sql-shared-client/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ apply plugin: 'elasticsearch.build'
1010
description = 'Code shared between jdbc and cli'
1111

1212
dependencies {
13-
compile xpackProject('plugin:sql:sql-proto')
13+
compile xpackProject('plugin:sql:sql-shared-proto')
1414
compile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
1515
testCompile "org.elasticsearch.test:framework:${version}"
1616
}
1717

1818
dependencyLicenses {
1919
mapping from: /jackson-.*/, to: 'jackson'
20-
mapping from: /sql-proto.*/, to: 'elasticsearch'
20+
mapping from: /sql-shared-proto.*/, to: 'elasticsearch'
2121
mapping from: /elasticsearch-cli.*/, to: 'elasticsearch'
2222
mapping from: /elasticsearch-core.*/, to: 'elasticsearch'
2323
mapping from: /lucene-.*/, to: 'lucene'

0 commit comments

Comments
 (0)