Skip to content

Commit

Permalink
Add Oracle connector
Browse files Browse the repository at this point in the history
  • Loading branch information
fgwang7w authored and highker committed Aug 19, 2020
1 parent c79b714 commit 49a2f19
Show file tree
Hide file tree
Showing 19 changed files with 1,417 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<dep.aws-sdk.version>1.11.445</dep.aws-sdk.version>
<dep.okhttp.version>3.9.0</dep.okhttp.version>
<dep.jdbi3.version>3.4.0</dep.jdbi3.version>
<dep.oracle.version>19.3.0.0</dep.oracle.version>
<dep.drift.version>1.25</dep.drift.version>
<dep.joda.version>2.10.5</dep.joda.version>
<dep.tempto.version>1.50</dep.tempto.version>
Expand Down Expand Up @@ -112,6 +113,7 @@
<module>presto-base-jdbc</module>
<module>presto-testing-docker</module>
<module>presto-mysql</module>
<module>presto-oracle</module>
<module>presto-postgresql</module>
<module>presto-redshift</module>
<module>presto-sqlserver</module>
Expand Down Expand Up @@ -351,6 +353,20 @@
<version>${project.version}</version>
</dependency>

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

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.14.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-geospatial</artifactId>
Expand Down
1 change: 1 addition & 0 deletions presto-docs/src/main/sphinx/connector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ from different data sources.
connector/memory
connector/mongodb
connector/mysql
connector/oracle
connector/pinot
connector/postgresql
connector/redis
Expand Down
71 changes: 71 additions & 0 deletions presto-docs/src/main/sphinx/connector/oracle.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
================
Oracle Connector
================

The Oracle connector allows querying and creating tables in an
external Oracle database. This can be used to join data between
different systems like Oracle and Hive, or between two different
Oracle instances.

Configuration
-------------

To configure the Oracle connector, create a catalog properties file
in ``etc/catalog`` named, for example, ``oracle.properties``, to
mount the Oracle connector as the ``oracle`` catalog.
Create the file with the following contents, replacing the
connection properties as appropriate for your setup:

.. code-block:: none
connector.name=oracle
connection-url=jdbc:oracle:thin:@example.net:1521/ORCLCDB
connection-user=root
connection-password=secret
Multiple Oracle Servers
^^^^^^^^^^^^^^^^^^^^^^^

You can have as many catalogs as you need, so if you have additional
Oracle servers, simply add another properties file to ``etc/catalog``
with a different name (making sure it ends in ``.properties``). For
example, if you name the property file ``sales.properties``, Presto
will create a catalog named ``sales`` using the configured connector.

Querying Oracle
---------------

The Oracle connector provides a schema for every Oracle *database*.
You can see the available Oracle databases by running ``SHOW SCHEMAS``::

SHOW SCHEMAS FROM oracle;

If you have a Oracle database named ``web``, you can view the tables
in this database by running ``SHOW TABLES``::

SHOW TABLES FROM oracle.web;

You can see a list of the columns in the ``clicks`` table in the ``web`` database
using either of the following::

DESCRIBE oracle.web.clicks;
SHOW COLUMNS FROM oracle.web.clicks;

Finally, you can access the ``clicks`` table in the ``web`` database::

SELECT * FROM oracle.web.clicks;

If you used a different name for your catalog properties file, use
that catalog name instead of ``oracle`` in the above examples.

Oracle Connector Limitations
----------------------------

The following SQL statements are not yet supported:

* :doc:`/sql/delete`
* :doc:`/sql/grant`
* :doc:`/sql/revoke`
* :doc:`/sql/show-grants`
* :doc:`/sql/show-roles`
* :doc:`/sql/show-role-grants`
223 changes: 223 additions & 0 deletions presto-oracle/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-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.241-SNAPSHOT</version>
</parent>

<artifactId>presto-oracle</artifactId>
<description>Presto - Oracle Connector</description>
<packaging>presto-plugin</packaging>

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

<dependencies>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>${dep.oracle.version}</version>
</dependency>

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

<dependency>
<groupId>com.facebook.airlift</groupId>
<artifactId>configuration</artifactId>
</dependency>

<dependency>
<groupId>com.facebook.airlift</groupId>
<artifactId>log</artifactId>
</dependency>

<dependency>
<groupId>com.facebook.airlift</groupId>
<artifactId>log-manager</artifactId>
<scope>runtime</scope>
</dependency>

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

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

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

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>

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

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-common</artifactId>
<scope>provided</scope>
</dependency>

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

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

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

<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<scope>provided</scope>
</dependency>

<!-- for testing -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-main</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-tpch</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.airlift</groupId>
<artifactId>testing</artifactId>
<scope>test</scope>
<version>${dep.airlift.version}</version>
</dependency>

<dependency>
<groupId>io.airlift.tpch</groupId>
<artifactId>tpch</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-tests</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
<version>1.14.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>oracle-xe</artifactId>
<scope>test</scope>
<version>1.14.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<profiles>
<profile>
<id>ci</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes combine.self="override" />
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- these tests take a very long time so only run them in the CI server -->
<excludes>
<exclude>**/TestOracleIntegrationSmokeTest.java</exclude>
<include>**/TestOracleDistributedQueries.java</include>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading

0 comments on commit 49a2f19

Please sign in to comment.