forked from prestodb/presto
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Added nosql and dynamo plugins #429
Open
ghost
wants to merge
1
commit into
Teradata:master
Choose a base branch
from
Zoomdata:base-nosql
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
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,122 @@ | ||
<?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"> | ||
<parent> | ||
<artifactId>presto-root</artifactId> | ||
<groupId>com.facebook.presto</groupId> | ||
<version>0.156</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>presto-base-plugin</artifactId> | ||
<description>Presto - Base plugin</description> | ||
|
||
<properties> | ||
<air.check.skip-extended>true</air.check.skip-extended> | ||
<air.check.skip-license>true</air.check.skip-license> | ||
|
||
<air.check.fail-checkstyle>false</air.check.fail-checkstyle> | ||
<air.check.skip-checkstyle>true</air.check.skip-checkstyle> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>bootstrap</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>log</artifactId> | ||
</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> | ||
|
||
<!-- 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> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.weakref</groupId> | ||
<artifactId>jmxutils</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.4</version> | ||
</dependency> | ||
|
||
<!-- for testing --> | ||
<dependency> | ||
<groupId>com.facebook.presto</groupId> | ||
<artifactId>presto-main</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>testing</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
94 changes: 94 additions & 0 deletions
94
presto-base-plugin-nosql/src/main/java/com/facebook/presto/baseplugin/BaseColumnHandle.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,94 @@ | ||
package com.facebook.presto.baseplugin; | ||
|
||
import com.facebook.presto.spi.ColumnHandle; | ||
import com.facebook.presto.spi.ColumnMetadata; | ||
import com.facebook.presto.spi.type.Type; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.apache.commons.lang3.builder.EqualsBuilder; | ||
import org.apache.commons.lang3.builder.HashCodeBuilder; | ||
|
||
import java.util.Objects; | ||
|
||
import static com.google.common.base.MoreObjects.toStringHelper; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
* Created by amehta on 6/13/16. | ||
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. Please remove that. |
||
*/ | ||
public class BaseColumnHandle implements ColumnHandle { | ||
private final String columnName; | ||
private final Type columnType; | ||
private final int ordinalPosition; | ||
|
||
@JsonCreator | ||
public BaseColumnHandle( | ||
@JsonProperty("columnName") String columnName, | ||
@JsonProperty("columnType") Type columnType, | ||
@JsonProperty("ordinalPosition") int ordinalPosition) | ||
{ | ||
this.columnName = requireNonNull(columnName, "columnName is null"); | ||
this.columnType = requireNonNull(columnType, "columnType is null"); | ||
this.ordinalPosition = ordinalPosition; | ||
} | ||
|
||
@JsonProperty | ||
public String getColumnName() | ||
{ | ||
return columnName; | ||
} | ||
|
||
@JsonProperty | ||
public Type getColumnType() | ||
{ | ||
return columnType; | ||
} | ||
|
||
@JsonProperty | ||
public int getOrdinalPosition() | ||
{ | ||
return ordinalPosition; | ||
} | ||
|
||
public ColumnMetadata toColumnMetadata() | ||
{ | ||
return new ColumnMetadata(columnName, columnType); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if(o == this){ | ||
return true; | ||
} | ||
if(o instanceof BaseColumnHandle){ | ||
BaseColumnHandle baseColumnHandle = (BaseColumnHandle) o; | ||
return new EqualsBuilder() | ||
.append(columnName, baseColumnHandle.columnName) | ||
.append(columnType, baseColumnHandle.columnType) | ||
.append(ordinalPosition, baseColumnHandle.ordinalPosition) | ||
.isEquals(); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return new HashCodeBuilder() | ||
.append(columnName) | ||
.append(columnType) | ||
.append(ordinalPosition) | ||
.toHashCode(); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return toStringHelper(this) | ||
.add("columnName", columnName) | ||
.add("columnType", columnType) | ||
.add("ordinalPosition", ordinalPosition) | ||
.toString(); | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
presto-base-plugin-nosql/src/main/java/com/facebook/presto/baseplugin/BaseConfig.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,104 @@ | ||
package com.facebook.presto.baseplugin; | ||
|
||
import com.facebook.presto.spi.ConnectorSession; | ||
import io.airlift.configuration.Config; | ||
import io.airlift.configuration.ConfigDescription; | ||
|
||
import java.util.Optional; | ||
import java.util.Properties; | ||
|
||
/** | ||
* Created by amehta on 6/13/16. | ||
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. ditto |
||
*/ | ||
public abstract class BaseConfig { | ||
private final Properties properties; | ||
|
||
public BaseConfig(){ | ||
this.properties = new Properties(); | ||
|
||
setProperty("basePlugin.cacheEnabled", false); | ||
setProperty("basePlugin.metastoreJdbcUrl", "jdbc:h2:~/h2/presto"); | ||
setProperty("basePlugin.metastoreUsername", "sa"); | ||
setProperty("basePlugin.metastorePassword", "sa"); | ||
setProperty("basePlugin.defaultSchemaName", "default_schema"); | ||
} | ||
|
||
protected void setProperty(String propertyName, Object value){ | ||
this.properties.setProperty(propertyName, value.toString()); | ||
} | ||
|
||
protected <T> T getProperty(String propertyName, Class<T> clazz, Optional<ConnectorSession> session){ | ||
//return session.isPresent() ? BaseUtils.getPropertyFromSessionConfig(propertyName, clazz, session.get(), this) : BaseUtils.getPropertyFromMap(propertyName, clazz, properties); | ||
return BaseUtils.getPropertyFromMap(propertyName, clazz, properties); | ||
} | ||
|
||
@Config("basePlugin.cacheEnabled") | ||
@ConfigDescription("Whether the cache is enabled for this plugin") | ||
public void setCacheEnabled(Boolean cacheEnabled){ | ||
setProperty("basePlugin.cacheEnabled", cacheEnabled); | ||
} | ||
|
||
public Boolean getCacheEnabled(Optional<ConnectorSession> session){ | ||
return getProperty("basePlugin.cacheEnabled", Boolean.class, session); | ||
} | ||
|
||
public Boolean getCacheEnabled(){ | ||
return getCacheEnabled(Optional.empty()); | ||
} | ||
|
||
@Config("basePlugin.metastoreJdbcUrl") | ||
@ConfigDescription("the location of the metadata store") | ||
public void setMetastoreJdbcUrl(String metastoreJdbcUrl){ | ||
setProperty("basePlugin.metastoreJdbcUrl", metastoreJdbcUrl); | ||
} | ||
|
||
public String getMetastoreJdbcUrl(Optional<ConnectorSession> session){ | ||
return getProperty("basePlugin.metastoreJdbcUrl", String.class, session); | ||
} | ||
|
||
public String getMetastoreJdbcUrl(){ | ||
return getMetastoreJdbcUrl(Optional.empty()); | ||
} | ||
|
||
@Config("basePlugin.metastoreUsername") | ||
@ConfigDescription("the username for connecting to the metadata store") | ||
public void setMetastoreUsername(String metastoreUsername){ | ||
setProperty("basePlugin.metastoreUsername", metastoreUsername); | ||
} | ||
|
||
public String getMetastoreUsername(Optional<ConnectorSession> session){ | ||
return getProperty("basePlugin.metastoreUsername", String.class, session); | ||
} | ||
|
||
public String getMetastoreUsername(){ | ||
return getMetastoreUsername(Optional.empty()); | ||
} | ||
|
||
@Config("basePlugin.metastorePassword") | ||
@ConfigDescription("the password for connecting to the metadata store") | ||
public void setMetastorePassword(String metastorePassword){ | ||
setProperty("basePlugin.metastorePassword", metastorePassword); | ||
} | ||
|
||
public String getMetastorePassword(Optional<ConnectorSession> session){ | ||
return getProperty("basePlugin.metastorePassword", String.class, session); | ||
} | ||
|
||
public String getMetastorePassword(){ | ||
return getMetastorePassword(Optional.empty()); | ||
} | ||
|
||
@Config("basePlugin.defaultSchemaName") | ||
@ConfigDescription("the name of the default schema for datasources that don't have schemas") | ||
public void setDefaultSchemaName(String defaultSchemaName){ | ||
setProperty("basePlugin.defaultSchemaName", defaultSchemaName); | ||
} | ||
|
||
public String getDefaultSchemaName(Optional<ConnectorSession> session){ | ||
return getProperty("basePlugin.defaultSchemaName", String.class, session); | ||
} | ||
|
||
public String getDefaultSchemaName(){ | ||
return getDefaultSchemaName(Optional.empty()); | ||
} | ||
} |
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.
Not necessary comment.