From bbb75906f9ad5a9882df60d88657832deb35abbf Mon Sep 17 00:00:00 2001 From: AbdulRehman Faraj Date: Mon, 23 Dec 2024 20:32:56 +0000 Subject: [PATCH] Revert 'various cleanup fixes (#2467)' --- .../connectors/db2as400/Db2As400EnvironmentProperties.java | 6 +++--- .../athena/connectors/docdb/DocDBMetadataHandler.java | 4 +--- .../athena/connectors/docdb/DocDBRecordHandler.java | 3 +-- .../athena/connectors/jdbc/JdbcEnvironmentProperties.java | 4 ++-- .../athena/connectors/oracle/OracleMetadataHandler.java | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/athena-db2-as400/src/main/java/com/amazonaws/athena/connectors/db2as400/Db2As400EnvironmentProperties.java b/athena-db2-as400/src/main/java/com/amazonaws/athena/connectors/db2as400/Db2As400EnvironmentProperties.java index e4473f833d..46dcde3b14 100644 --- a/athena-db2-as400/src/main/java/com/amazonaws/athena/connectors/db2as400/Db2As400EnvironmentProperties.java +++ b/athena-db2-as400/src/main/java/com/amazonaws/athena/connectors/db2as400/Db2As400EnvironmentProperties.java @@ -37,14 +37,14 @@ public Map connectionPropertiesToEnvironment(Map HashMap environment = new HashMap<>(); // now construct jdbc string - String connectionString = String.join("db2as400://jdbc:as400://", connectionProperties.get(HOST), - ";", connectionProperties.getOrDefault(JDBC_PARAMS, "")); + String connectionString = "db2as400://jdbc:as400://" + connectionProperties.get(HOST) + + ";" + connectionProperties.getOrDefault(JDBC_PARAMS, ""); if (connectionProperties.containsKey(SECRET_NAME)) { if (connectionProperties.containsKey(JDBC_PARAMS)) { // need to add delimiter connectionString = connectionString + ";"; } - connectionString = String.join(connectionString, ":${", connectionProperties.get(SECRET_NAME), "}"); + connectionString = connectionString + ":${" + connectionProperties.get(SECRET_NAME) + "}"; } logger.debug("Constructed connection string: {}", connectionString); diff --git a/athena-docdb/src/main/java/com/amazonaws/athena/connectors/docdb/DocDBMetadataHandler.java b/athena-docdb/src/main/java/com/amazonaws/athena/connectors/docdb/DocDBMetadataHandler.java index 8b57dd6685..5b21336bab 100644 --- a/athena-docdb/src/main/java/com/amazonaws/athena/connectors/docdb/DocDBMetadataHandler.java +++ b/athena-docdb/src/main/java/com/amazonaws/athena/connectors/docdb/DocDBMetadataHandler.java @@ -96,8 +96,6 @@ public class DocDBMetadataHandler //The Glue table property that indicates that a table matching the name of an DocDB table //is indeed enabled for use by this connector. private static final String DOCDB_METADATA_FLAG = "docdb-metadata-flag"; - //The prefix of a connection string - protected static final String DOCDB_CONN_STRING_PREFIX = "mongodb://"; //Used to filter out Glue tables which lack a docdb metadata flag. private static final TableFilter TABLE_FILTER = (Table table) -> table.parameters().containsKey(DOCDB_METADATA_FLAG); //The number of documents to scan when attempting to infer schema from an DocDB collection. @@ -136,7 +134,7 @@ private MongoClient getOrCreateConn(MetadataRequest request) { String connStr = getConnStr(request); if (configOptions.containsKey(SECRET_NAME) && !hasEmbeddedSecret(connStr)) { - connStr = String.join(connStr.substring(0, DOCDB_CONN_STRING_PREFIX.length()), "${", configOptions.get(SECRET_NAME), "}@", connStr.substring(DOCDB_CONN_STRING_PREFIX.length())); + connStr = connStr.substring(0, 10) + "${" + configOptions.get(SECRET_NAME) + "}@" + connStr.substring(10); } String endpoint = resolveSecrets(connStr); return connectionFactory.getOrCreateConn(endpoint); diff --git a/athena-docdb/src/main/java/com/amazonaws/athena/connectors/docdb/DocDBRecordHandler.java b/athena-docdb/src/main/java/com/amazonaws/athena/connectors/docdb/DocDBRecordHandler.java index 446578361f..d1d536ee73 100644 --- a/athena-docdb/src/main/java/com/amazonaws/athena/connectors/docdb/DocDBRecordHandler.java +++ b/athena-docdb/src/main/java/com/amazonaws/athena/connectors/docdb/DocDBRecordHandler.java @@ -49,7 +49,6 @@ import static com.amazonaws.athena.connector.lambda.handlers.GlueMetadataHandler.SOURCE_TABLE_PROPERTY; import static com.amazonaws.athena.connectors.docdb.DocDBFieldResolver.DEFAULT_FIELD_RESOLVER; import static com.amazonaws.athena.connectors.docdb.DocDBMetadataHandler.DOCDB_CONN_STR; -import static com.amazonaws.athena.connectors.docdb.DocDBMetadataHandler.DOCDB_CONN_STRING_PREFIX; /** * Handles data read record requests for the Athena DocumentDB Connector. @@ -111,7 +110,7 @@ private MongoClient getOrCreateConn(Split split) throw new RuntimeException(DOCDB_CONN_STR + " Split property is null! Unable to create connection."); } if (configOptions.containsKey(SECRET_NAME) && !hasEmbeddedSecret(connStr)) { - connStr = String.join(connStr.substring(0, DOCDB_CONN_STRING_PREFIX.length()), "${", configOptions.get(SECRET_NAME), "}@", connStr.substring(DOCDB_CONN_STRING_PREFIX.length())); + connStr = connStr.substring(0, 10) + "${" + configOptions.get(SECRET_NAME) + "}@" + connStr.substring(10); } String endpoint = resolveSecrets(connStr); return connectionFactory.getOrCreateConn(endpoint); diff --git a/athena-jdbc/src/main/java/com/amazonaws/athena/connectors/jdbc/JdbcEnvironmentProperties.java b/athena-jdbc/src/main/java/com/amazonaws/athena/connectors/jdbc/JdbcEnvironmentProperties.java index e25b14b60d..db4a349155 100644 --- a/athena-jdbc/src/main/java/com/amazonaws/athena/connectors/jdbc/JdbcEnvironmentProperties.java +++ b/athena-jdbc/src/main/java/com/amazonaws/athena/connectors/jdbc/JdbcEnvironmentProperties.java @@ -39,8 +39,8 @@ public Map connectionPropertiesToEnvironment(Map HashMap environment = new HashMap<>(); // now construct jdbc string - String connectionString = String.join(getConnectionStringPrefix(connectionProperties), connectionProperties.get(HOST), - ":", connectionProperties.get(PORT), getDatabase(connectionProperties), getJdbcParameters(connectionProperties)); + String connectionString = getConnectionStringPrefix(connectionProperties) + connectionProperties.get(HOST) + + ":" + connectionProperties.get(PORT) + getDatabase(connectionProperties) + getJdbcParameters(connectionProperties); environment.put(DEFAULT, connectionString); return environment; diff --git a/athena-oracle/src/main/java/com/amazonaws/athena/connectors/oracle/OracleMetadataHandler.java b/athena-oracle/src/main/java/com/amazonaws/athena/connectors/oracle/OracleMetadataHandler.java index cfa34e9057..0b4c42eeee 100644 --- a/athena-oracle/src/main/java/com/amazonaws/athena/connectors/oracle/OracleMetadataHandler.java +++ b/athena-oracle/src/main/java/com/amazonaws/athena/connectors/oracle/OracleMetadataHandler.java @@ -161,7 +161,7 @@ public void getPartitions(final BlockWriter blockWriter, final GetTableLayoutReq LOGGER.debug("{}: Schema {}, table {}", getTableLayoutRequest.getQueryId(), transformString(getTableLayoutRequest.getTableName().getSchemaName(), true), transformString(getTableLayoutRequest.getTableName().getTableName(), true)); try (Connection connection = getJdbcConnectionFactory().getConnection(getCredentialProvider())) { - List parameters = Arrays.asList(transformString(getTableLayoutRequest.getTableName().getTableName(), true)); + List parameters = Arrays.asList(transformString(getTableLayoutRequest.getTableName().getTableName(), true)); try (PreparedStatement preparedStatement = new PreparedStatementBuilder().withConnection(connection).withQuery(GET_PARTITIONS_QUERY).withParameters(parameters).build(); ResultSet resultSet = preparedStatement.executeQuery()) { // Return a single partition if no partitions defined