-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Closed
Teradata connector #12078
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...se-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/DriverManagerConnectionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
[![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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0"?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... allows you ...