Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teradata connector #12078

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<module>presto-postgresql</module>
<module>presto-redshift</module>
<module>presto-sqlserver</module>
<module>presto-teradata</module>
<module>presto-mongodb</module>
<module>presto-client</module>
<module>presto-parser</module>
Expand Down Expand Up @@ -398,6 +399,12 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-teradata</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.facebook.presto.hadoop</groupId>
<artifactId>hadoop-apache2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.plugin.jdbc;

import com.facebook.presto.spi.PrestoException;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import static com.facebook.presto.plugin.jdbc.JdbcErrorCode.DRIVER_NOT_FOUND;
import static java.util.Objects.requireNonNull;

public class DriverManagerConnectionFactory
implements ConnectionFactory
{
private final String connectionUrl;
private final Properties connectionProperties;

public DriverManagerConnectionFactory(String driverName, BaseJdbcConfig config)
{
this(driverName, config.getConnectionUrl(), basicConnectionProperties(config));
}

public static Properties basicConnectionProperties(BaseJdbcConfig config)
{
Properties connectionProperties = new Properties();
if (config.getConnectionUser() != null) {
connectionProperties.setProperty("user", config.getConnectionUser());
}
if (config.getConnectionPassword() != null) {
connectionProperties.setProperty("password", config.getConnectionPassword());
}
return connectionProperties;
}

public DriverManagerConnectionFactory(String driverName, String connectionUrl, Properties connectionProperties)
{
try {
Class.forName(driverName);
}
catch (ClassNotFoundException e) {
throw new PrestoException(DRIVER_NOT_FOUND, driverName + " not found");
}

this.connectionUrl = requireNonNull(connectionUrl, "connectionUrl is null");
this.connectionProperties = new Properties();
this.connectionProperties.putAll(requireNonNull(connectionProperties, "basicConnectionProperties is null"));
}

@Override
public Connection openConnection()
throws SQLException
{
return DriverManager.getConnection(connectionUrl, connectionProperties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import com.facebook.presto.spi.ErrorType;

import static com.facebook.presto.spi.ErrorType.EXTERNAL;
import static com.facebook.presto.spi.ErrorType.INTERNAL_ERROR;

public enum JdbcErrorCode
implements ErrorCodeSupplier
{
JDBC_ERROR(0, EXTERNAL),
JDBC_NON_TRANSIENT_ERROR(1, EXTERNAL);
JDBC_NON_TRANSIENT_ERROR(1, EXTERNAL),
DRIVER_NOT_FOUND(2, INTERNAL_ERROR);

private final ErrorCode errorCode;

Expand Down
6 changes: 6 additions & 0 deletions presto-server/src/main/provisio/presto.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@
</artifact>
</artifactSet>

<artifactSet to="plugin/teradata">
<artifact id="${project.groupId}:presto-teradata:zip:${project.version}">
<unpack />
</artifact>
</artifactSet>

<artifactSet to="plugin/raptor">
<artifact id="${project.groupId}:presto-raptor:zip:${project.version}">
<unpack />
Expand Down
42 changes: 42 additions & 0 deletions presto-teradata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Presto Teradata Plugin

This is a plugin for Presto that allow you to use Teradata Jdbc connection to connect to Teradata database.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... allows you ...


[![Presto-Connectors Member](https://img.shields.io/badge/presto--connectors-member-green.svg)](http://presto-connectors.ml)

## Connection Configuration

Create new properties file inside etc/catalog dir:

connector.name=teradata
# connection-url is the Teradata JDBC URL. You may use different configurations per environment.
# For more information, please visit
# [JDBC driver docs](https://developer.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_2.html)
connection-url=jdbc:teradata://<host>/TMODE=ANSI,CHARSET=UTF8
connection-user=<username>
connection-password=<password>

Note that if you are using Active Directory based user account and wanted Teradata to use AD to validate the credentials supplied, make sure you use the connection-url as below:

connection-url=jdbc:teradata://<host>/TMODE=ANSI,CHARSET=UTF8,LOGMECH=LDAP

If you like to use FASTEXPORT [(details here)](http://developer.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_2.html#BGBFBBEG), include the following changes:

connection-url=jdbc:teradata://<host>/TMODE=ANSI,CHARSET=UTF8,TYPE=FASTEXPORT
teradata.use-preparedstatement=true

## Building Presto Teradata JDBC Plugin

mvn clean install

## Adding Teradata Driver
Teradata Driver is not available in common repositories, so you will need to download it from Teradata and install manually in your repository.
Teradata’s JDBC drivers may be obtained from Teradata’s download page: [https://downloads.teradata.com/download/connectivity/jdbc-driver](https://downloads.teradata.com/download/connectivity/jdbc-driver).

Once you have the Teradata JDBC driver files downloaded, you can deploy the those files to presto plugin folder on coordinator and worker nodes.
For example, if the teradata driver files were jdbc-16.20.0.jar and config-16.20.0.jar and presto plugin folder is /usr/lib/presto/lib/plugin, use the following command to copy the files to the plugin folder.

cp jdbc-16.20.0.jar /usr/lib/presto/lib/plugin/teradata
cp config-16.20.0.jar /usr/lib/presto/lib/plugin/teradata

Restart the coordinator and worker processes and Teradata connector will work.
83 changes: 83 additions & 0 deletions presto-teradata/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation of this file doesn't look right; please 4 instead of 8.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-root</artifactId>
<version>0.215-SNAPSHOT</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the snapshot

</parent>

<groupId>com.facebook.presto</groupId>
<artifactId>presto-teradata</artifactId>
<description>Presto - Teradata Connector</description>
<packaging>presto-plugin</packaging>

<properties>
<air.main.basedir>${project.parent.basedir}</air.main.basedir>
</properties>

<dependencies>
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-base-jdbc</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>units</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>configuration</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>


<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<optional>true</optional>
</dependency>

<!-- Presto SPI -->
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-spi</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>slice</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>


<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<!--<version>2.8.2</version>-->
<scope>provided</scope>
</dependency>

</dependencies>
</project>
Loading