Skip to content

Commit

Permalink
Add the metadata portion of the TPC-DS connector
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Petrov authored and kokosing committed Jul 21, 2017
1 parent e07b91d commit 263b487
Show file tree
Hide file tree
Showing 12 changed files with 794 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Expand Up @@ -86,6 +86,7 @@
<module>presto-example-http</module>
<module>presto-local-file</module>
<module>presto-tpch</module>
<module>presto-tpcds</module>
<module>presto-raptor</module>
<module>presto-base-jdbc</module>
<module>presto-mysql</module>
Expand Down Expand Up @@ -516,6 +517,12 @@
<version>0.9</version>
</dependency>

<dependency>
<groupId>com.teradata.tpcds</groupId>
<artifactId>tpcds</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-all</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions presto-server/src/main/provisio/presto.xml
Expand Up @@ -122,6 +122,12 @@
</artifact>
</artifactSet>

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

<artifactSet to="plugin/teradata-functions">
<artifact id="${project.groupId}:presto-teradata-functions:zip:${project.version}">
<unpack />
Expand Down
48 changes: 48 additions & 0 deletions presto-tpcds/pom.xml
@@ -0,0 +1,48 @@
<?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>com.facebook.presto</groupId>
<artifactId>presto-root</artifactId>
<version>0.182-SNAPSHOT</version>
</parent>

<artifactId>presto-tpcds</artifactId>
<description>Presto - TPC-DS Connector</description>
<packaging>presto-plugin</packaging>

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

<dependencies>
<dependency>
<groupId>com.teradata.tpcds</groupId>
<artifactId>tpcds</artifactId>
</dependency>

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

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>

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

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,76 @@
/*
* 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.tpcds;

import com.facebook.presto.spi.ColumnHandle;
import com.facebook.presto.spi.type.Type;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Objects;

import static java.util.Objects.requireNonNull;

public class TpcdsColumnHandle
implements ColumnHandle
{
private final String columnName;
private final Type type;

@JsonCreator
public TpcdsColumnHandle(
@JsonProperty("columnName") String columnName,
@JsonProperty("type") Type type)
{
this.columnName = requireNonNull(columnName, "columnName is null");
this.type = requireNonNull(type, "type is null");
}

@JsonProperty
public String getColumnName()
{
return columnName;
}

@JsonProperty
public Type getType()
{
return type;
}

@Override
public String toString()
{
return "tpcds:" + columnName;
}

@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}
if ((o == null) || (getClass() != o.getClass())) {
return false;
}
TpcdsColumnHandle other = (TpcdsColumnHandle) o;
return Objects.equals(columnName, other.columnName);
}

@Override
public int hashCode()
{
return Objects.hash(columnName);
}
}
@@ -0,0 +1,95 @@
/*
* 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.tpcds;

import com.facebook.presto.spi.ConnectorHandleResolver;
import com.facebook.presto.spi.connector.Connector;
import com.facebook.presto.spi.connector.ConnectorContext;
import com.facebook.presto.spi.connector.ConnectorFactory;
import com.facebook.presto.spi.connector.ConnectorMetadata;
import com.facebook.presto.spi.connector.ConnectorNodePartitioningProvider;
import com.facebook.presto.spi.connector.ConnectorRecordSetProvider;
import com.facebook.presto.spi.connector.ConnectorSplitManager;
import com.facebook.presto.spi.connector.ConnectorTransactionHandle;
import com.facebook.presto.spi.transaction.IsolationLevel;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

import java.util.Map;

import static com.google.common.base.Preconditions.checkState;

public class TpcdsConnectorFactory
implements ConnectorFactory
{
private final int defaultSplitsPerNode;

public TpcdsConnectorFactory()
{
this(Runtime.getRuntime().availableProcessors());
}

public TpcdsConnectorFactory(int defaultSplitsPerNode)
{
checkState(defaultSplitsPerNode > 0, "default splits per node is negative");
this.defaultSplitsPerNode = defaultSplitsPerNode;
}

@Override
public String getName()
{
return "tpcds";
}

@Override
public ConnectorHandleResolver getHandleResolver()
{
return new TpcdsHandleResolver();
}

@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context)
{
return new Connector() {
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
return TpcdsTransactionHandle.INSTANCE;
}

@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle)
{
return new TpcdsMetadata();
}

@Override
public ConnectorSplitManager getSplitManager()
{
throw new NotImplementedException();
}

@Override
public ConnectorRecordSetProvider getRecordSetProvider()
{
throw new NotImplementedException();
}

@Override
public ConnectorNodePartitioningProvider getNodePartitioningProvider()
{
throw new NotImplementedException();
}
};
}
}
@@ -0,0 +1,63 @@
/*
* 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.tpcds;

import com.facebook.presto.spi.ColumnHandle;
import com.facebook.presto.spi.ConnectorHandleResolver;
import com.facebook.presto.spi.ConnectorSplit;
import com.facebook.presto.spi.ConnectorTableHandle;
import com.facebook.presto.spi.ConnectorTableLayoutHandle;
import com.facebook.presto.spi.connector.ConnectorPartitioningHandle;
import com.facebook.presto.spi.connector.ConnectorTransactionHandle;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

public class TpcdsHandleResolver
implements ConnectorHandleResolver
{
@Override
public Class<? extends ConnectorTableHandle> getTableHandleClass()
{
return TpcdsTableHandle.class;
}

@Override
public Class<? extends ConnectorTableLayoutHandle> getTableLayoutHandleClass()
{
return TpcdsTableLayoutHandle.class;
}

@Override
public Class<? extends ColumnHandle> getColumnHandleClass()
{
return TpcdsColumnHandle.class;
}

@Override
public Class<? extends ConnectorSplit> getSplitClass()
{
throw new NotImplementedException();
}

@Override
public Class<? extends ConnectorTransactionHandle> getTransactionHandleClass()
{
return TpcdsTransactionHandle.class;
}

@Override
public Class<? extends ConnectorPartitioningHandle> getPartitioningHandleClass()
{
return TpcdsPartitioningHandle.class;
}
}

0 comments on commit 263b487

Please sign in to comment.