From 55aae4a88f3350726a7db9a5ae014017cbdd276c Mon Sep 17 00:00:00 2001 From: Star Poon Date: Thu, 22 Aug 2024 10:01:18 +0900 Subject: [PATCH 1/2] Fix RequestParsingException message --- .../gateway/ha/router/TrinoQueryProperties.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java b/gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java index 15c3d131b..ad6cc9808 100644 --- a/gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java +++ b/gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java @@ -75,6 +75,7 @@ import static com.google.common.io.BaseEncoding.base64Url; import static io.airlift.json.JsonCodec.jsonCodec; import static java.lang.Math.toIntExact; +import static java.lang.String.format; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNullElse; @@ -199,7 +200,7 @@ private void processRequestBody(HttpServletRequest request, RequestAnalyzerConfi schemaBuilder.addAll(tables.stream().map(q -> q.getParts().get(1)).iterator()); schemas = schemaBuilder.build(); catalogSchemaBuilder.addAll( - tables.stream().map(qualifiedName -> String.format("%s.%s", qualifiedName.getParts().getFirst(), qualifiedName.getParts().get(1))).iterator()); + tables.stream().map(qualifiedName -> format("%s.%s", qualifiedName.getParts().getFirst(), qualifiedName.getParts().get(1))).iterator()); catalogSchemas = catalogSchemaBuilder.build(); isQueryParsingSuccessful = true; } @@ -230,7 +231,7 @@ private Map getPreparedStatements(HttpServletRequest request) for (String preparedStatement : preparedStatementsArray) { String[] nameValue = preparedStatement.split("="); if (nameValue.length != 2) { - throw new RequestParsingException(String.format("preparedStatement must be formatted as name=value, but is %s", preparedStatement)); + throw new RequestParsingException(format("preparedStatement must be formatted as name=value, but is %s", preparedStatement)); } preparedStatementsMapBuilder.put(URLDecoder.decode(nameValue[0], UTF_8), URLDecoder.decode(decodePreparedStatementFromHeader(nameValue[1]), UTF_8)); } @@ -350,7 +351,7 @@ private void setCatalogAndSchemaNameFromSchemaQualifiedName( if (schemaOptional.isEmpty()) { schemaBuilder.add(defaultSchema.orElseThrow(this::unsetDefaultExceptionSupplier)); catalogBuilder.add(defaultCatalog.orElseThrow(this::unsetDefaultExceptionSupplier)); - catalogSchemaBuilder.add(String.format("%s.%s", defaultCatalog, defaultSchema)); + catalogSchemaBuilder.add(format("%s.%s", defaultCatalog, defaultSchema)); } else { QualifiedName schema = schemaOptional.orElseThrow(); @@ -358,11 +359,11 @@ private void setCatalogAndSchemaNameFromSchemaQualifiedName( case 1: schemaBuilder.add(schema.getParts().getFirst()); catalogBuilder.add(defaultCatalog.orElseThrow(this::unsetDefaultExceptionSupplier)); - catalogSchemaBuilder.add(String.format("%s.%s", defaultCatalog, schema.getParts().getFirst())); + catalogSchemaBuilder.add(format("%s.%s", defaultCatalog, schema.getParts().getFirst())); case 2: schemaBuilder.add(schema.getParts().get(1)); catalogBuilder.add(schema.getParts().getFirst()); - catalogSchemaBuilder.add(String.format("%s.%s", schema.getParts().getFirst(), schema.getParts().getLast())); + catalogSchemaBuilder.add(format("%s.%s", schema.getParts().getFirst(), schema.getParts().getLast())); default: log.error("Schema has >2 parts: " + schema); } @@ -433,7 +434,7 @@ private QualifiedName parseIdentifierStringToQualifiedName(String name) if (!inQuotes) { if (i != start) { log.error("Illegal position for first quote character in table name: %s", name); - throw new ParsingException("Illegal position for first quote character in table name: %s"); + throw new ParsingException(format("Illegal position for first quote character in table name: %s", name)); } start = start + 1; partQuoted = true; From c7c9b854203dda12d203710d7e6b684781371f5c Mon Sep 17 00:00:00 2001 From: Star Poon Date: Thu, 22 Aug 2024 10:02:16 +0900 Subject: [PATCH 2/2] Use and require Java 22 --- .github/workflows/ci.yml | 3 ++- .java-version | 2 +- docs/development.md | 4 ++-- docs/installation.md | 2 +- gateway-ha/pom.xml | 8 ++++---- .../trino/gateway/ha/router/TrinoQueryProperties.java | 3 ++- pom.xml | 10 +++++++--- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c1d62053..707f50591 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,9 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - java-version: [21, 22] + java-version: [22, 23-ea] timeout-minutes: 20 steps: - name: Checkout source diff --git a/.java-version b/.java-version index 5f39e9144..2bd5a0a98 100644 --- a/.java-version +++ b/.java-version @@ -1 +1 @@ -21.0 +22 diff --git a/docs/development.md b/docs/development.md index c70316a8f..8d353ae7d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -3,7 +3,7 @@ ## Build requirements * Mac OS X or Linux -* Java 21+, 64-bit +* Java 22+, 64-bit * Docker #### Running Trino Gateway in your IDE @@ -21,7 +21,7 @@ or execute the following command: #### Locally -This project requires Java 21. Note that higher version of Java have not been +This project requires Java 22. Note that higher version of Java have not been verified and may run into unexpected issues. Run `./mvnw clean install` to build `trino-gateway`. VM options required for diff --git a/docs/installation.md b/docs/installation.md index 71b7eaba1..b45f05d9e 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -16,7 +16,7 @@ Consider the following requirements for your Trino Gateway installation. ### Java -Trino Gateway requires a Java 21 runtime. Older versions of Java can not be +Trino Gateway requires a Java 22 runtime. Older versions of Java can not be used. Newer versions might work but are not tested. Verify the Java version on your system with `java -version`. diff --git a/gateway-ha/pom.xml b/gateway-ha/pom.xml index 726b2a392..10644624d 100644 --- a/gateway-ha/pom.xml +++ b/gateway-ha/pom.xml @@ -63,7 +63,7 @@ com.google.errorprone error_prone_annotations - true + ${dep.errorprone.version} @@ -191,7 +191,7 @@ io.trino trino-parser - 440 + ${dep.trino.version} @@ -292,7 +292,7 @@ io.trino trino-jdbc - 449 + ${dep.trino.version} runtime @@ -335,7 +335,7 @@ io.trino trino-client - 444 + ${dep.trino.version} test diff --git a/gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java b/gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java index ad6cc9808..506acf706 100644 --- a/gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java +++ b/gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java @@ -41,6 +41,7 @@ import io.trino.sql.tree.Execute; import io.trino.sql.tree.Identifier; import io.trino.sql.tree.Node; +import io.trino.sql.tree.NodeLocation; import io.trino.sql.tree.QualifiedName; import io.trino.sql.tree.RenameMaterializedView; import io.trino.sql.tree.RenameSchema; @@ -434,7 +435,7 @@ private QualifiedName parseIdentifierStringToQualifiedName(String name) if (!inQuotes) { if (i != start) { log.error("Illegal position for first quote character in table name: %s", name); - throw new ParsingException(format("Illegal position for first quote character in table name: %s", name)); + throw new ParsingException(format("Illegal position for first quote character in table name: %s", name), new NodeLocation(1, i)); } start = start + 1; partQuoted = true; diff --git a/pom.xml b/pom.xml index bf9294df8..a1d017780 100644 --- a/pom.xml +++ b/pom.xml @@ -39,11 +39,15 @@ UTF-8 UTF-8 - 21 - 21 + 22 + 22 true true clean verify -DskipTests + + + 2.29.2 + 454 @@ -103,7 +107,7 @@ com.google.errorprone error_prone_core - 2.24.0 + ${dep.errorprone.version}