From ebf8eb440ca214b989f1f143b761be0edc3613a8 Mon Sep 17 00:00:00 2001 From: Jithendar12 Date: Mon, 2 Dec 2024 15:54:11 +0530 Subject: [PATCH] Add port number as a DBS_PORT parameter in Teradata JDBC Connection String --- .../TeradataEnvironmentProperties.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/athena-teradata/src/main/java/com/amazonaws/athena/connectors/teradata/TeradataEnvironmentProperties.java b/athena-teradata/src/main/java/com/amazonaws/athena/connectors/teradata/TeradataEnvironmentProperties.java index 0b41bbcb0f..bbc2bfee02 100644 --- a/athena-teradata/src/main/java/com/amazonaws/athena/connectors/teradata/TeradataEnvironmentProperties.java +++ b/athena-teradata/src/main/java/com/amazonaws/athena/connectors/teradata/TeradataEnvironmentProperties.java @@ -21,12 +21,31 @@ import com.amazonaws.athena.connectors.jdbc.JdbcEnvironmentProperties; +import java.util.HashMap; import java.util.Map; import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.DATABASE; +import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.DEFAULT; +import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.HOST; +import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.PORT; public class TeradataEnvironmentProperties extends JdbcEnvironmentProperties { + @Override + public Map connectionPropertiesToEnvironment(Map connectionProperties) + { + HashMap environment = new HashMap<>(); + // Default port for teradata is 1025 + String port = connectionProperties.getOrDefault(PORT, "1025"); + + // Construct the JDBC connection string and include the port as a DBS_PORT parameter + String connectionString = getConnectionStringPrefix(connectionProperties) + connectionProperties.get(HOST) + + getDatabase(connectionProperties) + ",DBS_PORT=" + port + getJdbcParameters(connectionProperties); + + environment.put(DEFAULT, connectionString); + return environment; + } + @Override protected String getConnectionStringPrefix(Map connectionProperties) {