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) {