Browse Source

QL: Upgrade ANTLR and move it into QL (#76358)

* 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>
Costin Leau 4 years ago
parent
commit
6d7b3458bd

+ 1 - 2
x-pack/plugin/eql/build.gradle

@@ -10,7 +10,7 @@ esplugin {
 
 ext {
   // EQL dependency versions
-  antlrVersion = "4.5.3"
+  antlrVersion = "4.9.2"
 }
 
 archivesBaseName = 'x-pack-eql'
@@ -18,7 +18,6 @@ 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')

+ 0 - 1
x-pack/plugin/eql/licenses/antlr4-runtime-4.5.3.jar.sha1

@@ -1 +0,0 @@
-2609e36f18f7e8d593cc1cddfb2ac776dc96b8e0

+ 5 - 0
x-pack/plugin/ql/build.gradle

@@ -8,6 +8,10 @@ esplugin {
   extendedPlugins = ['x-pack-core']
 }
 
+ext {
+  antlrVersion = "4.9.2"
+}
+
 archivesBaseName = 'x-pack-ql'
 
 dependencies {
@@ -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 - 0
x-pack/plugin/ql/licenses/antlr4-runtime-4.9.2.jar.sha1

@@ -0,0 +1 @@
+ece33ec76e002dfde574cf7b57451a91a99185c5

+ 0 - 0
x-pack/plugin/eql/licenses/antlr4-runtime-LICENSE.txt → x-pack/plugin/ql/licenses/antlr4-runtime-LICENSE.txt


+ 0 - 0
x-pack/plugin/eql/licenses/antlr4-runtime-NOTICE.txt → x-pack/plugin/ql/licenses/antlr4-runtime-NOTICE.txt


+ 1 - 2
x-pack/plugin/sql/build.gradle

@@ -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"
@@ -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'))))

+ 0 - 1
x-pack/plugin/sql/licenses/antlr4-runtime-4.5.3.jar.sha1

@@ -1 +0,0 @@
-2609e36f18f7e8d593cc1cddfb2ac776dc96b8e0

+ 0 - 26
x-pack/plugin/sql/licenses/antlr4-runtime-LICENSE.txt

@@ -1,26 +0,0 @@
-[The "BSD license"]
-Copyright (c) 2015 Terence Parr, Sam Harwell
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- 1. Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in the
-    documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
-    derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 0 - 0
x-pack/plugin/sql/licenses/antlr4-runtime-NOTICE.txt


+ 1 - 1
x-pack/plugin/sql/qa/jdbc/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcErrorsTestCase.java

@@ -107,7 +107,7 @@ public abstract class JdbcErrorsTestCase extends JdbcIntegrationTestCase {
         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>, "));
         }
     }
 

+ 1 - 1
x-pack/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/cli/ErrorsTestCase.java

@@ -93,7 +93,7 @@ public abstract class ErrorsTestCase extends CliIntegrationTestCase implements o
         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>, ")
         );
     }
 

+ 1 - 1
x-pack/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/rest/RestSqlTestCase.java

@@ -453,7 +453,7 @@ public abstract class RestSqlTestCase extends BaseRestSqlTestCase implements Err
         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>, ")
         );
     }