Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the metadata portion of the TPC-DS connector
- Loading branch information
Showing
12 changed files
with
794 additions
and
0 deletions.
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
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,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> |
76 changes: 76 additions & 0 deletions
76
presto-tpcds/src/main/java/com/facebook/presto/tpcds/TpcdsColumnHandle.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,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); | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
presto-tpcds/src/main/java/com/facebook/presto/tpcds/TpcdsConnectorFactory.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,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(); | ||
} | ||
}; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
presto-tpcds/src/main/java/com/facebook/presto/tpcds/TpcdsHandleResolver.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,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; | ||
} | ||
} |
Oops, something went wrong.