Skip to content

Commit

Permalink
QL: Upgrade ANTLR and move it into QL (#76358) (#76383)
Browse files Browse the repository at this point in the history
* QL: Upgrade ANTLR and move it into QL

Following #76288, upgrade ANTLR library to benefit from the various
improvements made in most recent releases in particular better
performance and error messages.

Looking at the changelog, since version 4.7.2 most changes in ANTLR seem
to have occurred in non-Java targets however this commit upgrades to
ANTLR 4.9.2 to benefit from the dependency updates (such as
StringTemplate).

Additionally move the library into QL to consolidate its use across QL
projects.

Relates #74448
Fix #76354

* Fix matching on error message

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
costin and elasticmachine committed Aug 12, 2021
1 parent 174a923 commit 38b00c8
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 35 deletions.
3 changes: 1 addition & 2 deletions x-pack/plugin/eql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ esplugin {

ext {
// EQL dependency versions
antlrVersion = "4.5.3"
antlrVersion = "4.9.2"
}

archivesBaseName = 'x-pack-eql'

dependencies {
compileOnly project(path: xpackModule('core'))
compileOnly(project(':modules:lang-painless:spi'))
api "org.antlr:antlr4-runtime:${antlrVersion}"
compileOnly project(xpackModule('ql'))

testImplementation project(':test:framework')
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugin/eql/licenses/antlr4-runtime-4.5.3.jar.sha1

This file was deleted.

5 changes: 5 additions & 0 deletions x-pack/plugin/ql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ esplugin {
extendedPlugins = ['x-pack-core']
}

ext {
antlrVersion = "4.9.2"
}

archivesBaseName = 'x-pack-ql'

dependencies {
Expand All @@ -17,4 +21,5 @@ dependencies {
testImplementation(project(xpackModule('ql:test-fixtures'))) {
exclude group: 'org.elasticsearch.plugin', module: 'ql'
}
api "org.antlr:antlr4-runtime:${antlrVersion}"
}
1 change: 1 addition & 0 deletions x-pack/plugin/ql/licenses/antlr4-runtime-4.9.2.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ece33ec76e002dfde574cf7b57451a91a99185c5
3 changes: 1 addition & 2 deletions x-pack/plugin/sql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ esplugin {
}

ext {
antlrVersion = "4.9.2"
// SQL dependency versions
jlineVersion = "3.14.1"
antlrVersion = "4.5.3"

// SQL test dependency versions
csvjdbcVersion = "1.0.34"
Expand All @@ -33,7 +33,6 @@ dependencies {
compileOnly(project(':modules:lang-painless:spi'))
api project('sql-action')
api project(':modules:aggs-matrix-stats')
api "org.antlr:antlr4-runtime:${antlrVersion}"
compileOnly project(path: xpackModule('ql'))
testImplementation project(':test:framework')
testImplementation(testArtifact(project(xpackModule('core'))))
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugin/sql/licenses/antlr4-runtime-4.5.3.jar.sha1

This file was deleted.

26 changes: 0 additions & 26 deletions x-pack/plugin/sql/licenses/antlr4-runtime-LICENSE.txt

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void testSelectScoreSubField() throws IOException, SQLException {
index("test", body -> body.field("foo", 1));
try (Connection c = esJdbc()) {
SQLException e = expectThrows(SQLException.class, () -> c.prepareStatement("SELECT SCORE().bar FROM test").executeQuery());
assertThat(e.getMessage(), startsWith("line 1:15: extraneous input '.' expecting {<EOF>, ','"));
assertThat(e.getMessage(), startsWith("line 1:15: mismatched input '.' expecting {<EOF>, "));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testSelectScoreSubField() throws Exception {
index("test", body -> body.field("foo", 1));
assertThat(
command("SELECT SCORE().bar FROM test"),
startsWith(START + "Bad request [[3;33;22mline 1:15: extraneous input '.' expecting {<EOF>, ',',")
startsWith(START + "Bad request [[3;33;22mline 1:15: mismatched input '.' expecting {<EOF>, ")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public void testSelectScoreSubField() throws Exception {
index("{\"foo\":1}");
expectBadRequest(
() -> runSql(randomMode(), "SELECT SCORE().bar FROM test"),
containsString("line 1:15: extraneous input '.' expecting {<EOF>, ','")
containsString("line 1:15: mismatched input '.' expecting {<EOF>, ")
);
}

Expand Down

0 comments on commit 38b00c8

Please sign in to comment.