Skip to content

Commit

Permalink
Presto Druid connector
Browse files Browse the repository at this point in the history
Co-authored-by: Puneet Jaiswal <punit.kj@gmail.com>
  • Loading branch information
2 people authored and findepi committed Jun 20, 2020
1 parent c6aff01 commit fcb9163
Show file tree
Hide file tree
Showing 29 changed files with 1,716 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -154,7 +154,7 @@ jobs:
!presto-sqlserver,!presto-postgresql,!presto-mysql,
!presto-oracle,
!presto-kudu,
!presto-phoenix,!presto-iceberg,
!presto-phoenix,!presto-iceberg,!presto-druid,
!presto-docs,!presto-server,!presto-server-rpm'
test:
Expand All @@ -177,7 +177,7 @@ jobs:
- "presto-sqlserver,presto-postgresql,presto-mysql"
- "presto-oracle"
- "presto-kudu"
- "presto-phoenix,presto-iceberg"
- "presto-phoenix,presto-iceberg,presto-druid"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -145,6 +145,7 @@
<module>presto-bigquery</module>
<module>presto-pinot</module>
<module>presto-oracle</module>
<module>presto-druid</module>
</modules>

<dependencyManagement>
Expand Down
Expand Up @@ -48,6 +48,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.Set;
Expand Down Expand Up @@ -249,6 +250,12 @@ public List<JdbcColumnHandle> getColumns(ConnectorSession session, JdbcTableHand
int allColumns = 0;
List<JdbcColumnHandle> columns = new ArrayList<>();
while (resultSet.next()) {
// skip if table doesn't match expected
if (!(Objects.equals(tableHandle.getCatalogName(), resultSet.getString("TABLE_CAT"))
&& Objects.equals(tableHandle.getSchemaName(), resultSet.getString("TABLE_SCHEM"))
&& Objects.equals(tableHandle.getTableName(), resultSet.getString("TABLE_NAME")))) {
continue;
}
allColumns++;
String columnName = resultSet.getString("COLUMN_NAME");
JdbcTypeHandle typeHandle = new JdbcTypeHandle(
Expand Down Expand Up @@ -290,7 +297,7 @@ public List<JdbcColumnHandle> getColumns(ConnectorSession session, JdbcTableHand
}
}

protected static ResultSet getColumns(JdbcTableHandle tableHandle, DatabaseMetaData metadata)
protected ResultSet getColumns(JdbcTableHandle tableHandle, DatabaseMetaData metadata)
throws SQLException
{
return metadata.getColumns(
Expand Down
Expand Up @@ -156,7 +156,7 @@ else if (javaType == Slice.class) {
protected String getProjection(List<JdbcColumnHandle> columns)
{
if (columns.isEmpty()) {
return "null";
return "1";
}
return columns.stream()
.map(JdbcColumnHandle::getColumnName)
Expand Down
153 changes: 153 additions & 0 deletions presto-druid/pom.xml
@@ -0,0 +1,153 @@
<?xml version="1.0"?>
<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>io.prestosql</groupId>
<artifactId>presto-root</artifactId>
<version>337-SNAPSHOT</version>
</parent>

<artifactId>presto-druid</artifactId>
<description>Presto - Druid Jdbc Connector</description>
<packaging>presto-plugin</packaging>

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

<dependencies>
<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-base-jdbc</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.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>compile</scope>
</dependency>

<!-- Druid JDBC Connector -->
<dependency>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-core</artifactId>
<version>1.16.0</version>
<!-- Excluded as they bring in duplicate classes -->
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

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

<!-- SPI -->
<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-spi</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>slice</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>io.prestosql</groupId>
<artifactId>presto-main</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-tpch</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-tests</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-testing</artifactId>
<scope>test</scope>
</dependency>

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

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<scope>test</scope>
</dependency>

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

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.14.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,40 @@
/*
* 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 io.prestosql.plugin.druid;

import io.prestosql.spi.ErrorCode;
import io.prestosql.spi.ErrorCodeSupplier;
import io.prestosql.spi.ErrorType;

import static io.prestosql.spi.ErrorType.EXTERNAL;

public enum DruidErrorCode
implements ErrorCodeSupplier
{
DRUID_DDL_NOT_SUPPORTED(0, EXTERNAL),
DRUID_DML_NOT_SUPPORTED(1, EXTERNAL);

private final ErrorCode errorCode;

DruidErrorCode(int code, ErrorType type)
{
errorCode = new ErrorCode(code + 0x0510_0000, name(), type);
}

@Override
public ErrorCode toErrorCode()
{
return null;
}
}

0 comments on commit fcb9163

Please sign in to comment.