Skip to content

Commit f240d86

Browse files
committed
Add CLP connector
1 parent c8566b4 commit f240d86

33 files changed

+3618
-0
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
<module>presto-native-sidecar-plugin</module>
215215
<module>presto-base-arrow-flight</module>
216216
<module>presto-function-server</module>
217+
<module>presto-clp</module>
217218
</modules>
218219

219220
<dependencyManagement>
@@ -819,6 +820,12 @@
819820
<version>${project.version}</version>
820821
</dependency>
821822

823+
<dependency>
824+
<groupId>com.facebook.presto</groupId>
825+
<artifactId>presto-clp</artifactId>
826+
<version>${project.version}</version>
827+
</dependency>
828+
822829
<dependency>
823830
<groupId>com.facebook.presto</groupId>
824831
<artifactId>presto-expressions</artifactId>

presto-clp/pom.xml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?xml version="1.0"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>com.facebook.presto</groupId>
8+
<artifactId>presto-root</artifactId>
9+
<version>0.293-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>presto-clp</artifactId>
13+
<description>Presto - CLP Connector</description>
14+
<packaging>presto-plugin</packaging>
15+
16+
<properties>
17+
<air.main.basedir>${project.parent.basedir}</air.main.basedir>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>mysql</groupId>
23+
<artifactId>mysql-connector-java</artifactId>
24+
<scope>runtime</scope>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>com.facebook.airlift</groupId>
29+
<artifactId>bootstrap</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>com.facebook.airlift</groupId>
34+
<artifactId>json</artifactId>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>com.facebook.airlift</groupId>
39+
<artifactId>log</artifactId>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>com.facebook.airlift</groupId>
44+
<artifactId>configuration</artifactId>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>com.google.inject</groupId>
49+
<artifactId>guice</artifactId>
50+
</dependency>
51+
52+
<dependency>
53+
<groupId>com.google.code.findbugs</groupId>
54+
<artifactId>jsr305</artifactId>
55+
<optional>true</optional>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>com.google.guava</groupId>
60+
<artifactId>guava</artifactId>
61+
</dependency>
62+
63+
<dependency>
64+
<groupId>javax.inject</groupId>
65+
<artifactId>javax.inject</artifactId>
66+
</dependency>
67+
68+
<dependency>
69+
<groupId>com.fasterxml.jackson.core</groupId>
70+
<artifactId>jackson-annotations</artifactId>
71+
<scope>provided</scope>
72+
</dependency>
73+
74+
<dependency>
75+
<groupId>com.facebook.presto</groupId>
76+
<artifactId>presto-spi</artifactId>
77+
<scope>provided</scope>
78+
</dependency>
79+
80+
<dependency>
81+
<groupId>com.facebook.presto</groupId>
82+
<artifactId>presto-common</artifactId>
83+
<scope>provided</scope>
84+
</dependency>
85+
86+
<dependency>
87+
<groupId>io.airlift</groupId>
88+
<artifactId>units</artifactId>
89+
<scope>provided</scope>
90+
</dependency>
91+
92+
<dependency>
93+
<groupId>io.airlift</groupId>
94+
<artifactId>slice</artifactId>
95+
<scope>provided</scope>
96+
</dependency>
97+
98+
<dependency>
99+
<groupId>org.testng</groupId>
100+
<artifactId>testng</artifactId>
101+
<scope>test</scope>
102+
</dependency>
103+
104+
<dependency>
105+
<groupId>com.facebook.presto</groupId>
106+
<artifactId>presto-main</artifactId>
107+
<scope>test</scope>
108+
</dependency>
109+
110+
<dependency>
111+
<groupId>com.facebook.presto</groupId>
112+
<artifactId>presto-analyzer</artifactId>
113+
<scope>test</scope>
114+
</dependency>
115+
116+
<dependency>
117+
<groupId>com.h2database</groupId>
118+
<artifactId>h2</artifactId>
119+
<scope>test</scope>
120+
</dependency>
121+
122+
<dependency>
123+
<groupId>com.facebook.presto</groupId>
124+
<artifactId>presto-parser</artifactId>
125+
<scope>test</scope>
126+
</dependency>
127+
128+
<dependency>
129+
<groupId>org.apache.commons</groupId>
130+
<artifactId>commons-math3</artifactId>
131+
<scope>test</scope>
132+
</dependency>
133+
</dependencies>
134+
</project>
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.facebook.presto.plugin.clp;
15+
16+
import com.facebook.presto.common.type.Type;
17+
import com.facebook.presto.spi.ColumnHandle;
18+
import com.facebook.presto.spi.ColumnMetadata;
19+
import com.fasterxml.jackson.annotation.JsonCreator;
20+
import com.fasterxml.jackson.annotation.JsonProperty;
21+
22+
import java.util.Objects;
23+
24+
import static com.google.common.base.MoreObjects.toStringHelper;
25+
26+
public class ClpColumnHandle
27+
implements ColumnHandle
28+
{
29+
private final String columnName;
30+
private final String originalColumnName;
31+
private final Type columnType;
32+
private final boolean nullable;
33+
34+
@JsonCreator
35+
public ClpColumnHandle(
36+
@JsonProperty("columnName") String columnName,
37+
@JsonProperty("originalColumnName") String originalColumnName,
38+
@JsonProperty("columnType") Type columnType,
39+
@JsonProperty("nullable") boolean nullable)
40+
{
41+
this.columnName = columnName;
42+
this.originalColumnName = originalColumnName;
43+
this.columnType = columnType;
44+
this.nullable = nullable;
45+
}
46+
47+
public ClpColumnHandle(String columnName, Type columnType, boolean nullable)
48+
{
49+
this(columnName, columnName, columnType, nullable);
50+
}
51+
52+
@JsonProperty
53+
public String getColumnName()
54+
{
55+
return columnName;
56+
}
57+
58+
@JsonProperty
59+
public String getOriginalColumnName()
60+
{
61+
return originalColumnName;
62+
}
63+
64+
@JsonProperty
65+
public Type getColumnType()
66+
{
67+
return columnType;
68+
}
69+
70+
@JsonProperty
71+
public boolean isNullable()
72+
{
73+
return nullable;
74+
}
75+
76+
public ColumnMetadata getColumnMetadata()
77+
{
78+
ColumnMetadata.Builder builder = ColumnMetadata.builder()
79+
.setName(columnName)
80+
.setType(columnType)
81+
.setNullable(nullable);
82+
return builder.build();
83+
}
84+
85+
@Override
86+
public int hashCode()
87+
{
88+
return Objects.hash(columnName, columnType);
89+
}
90+
91+
@Override
92+
public boolean equals(Object obj)
93+
{
94+
if (this == obj) {
95+
return true;
96+
}
97+
if (obj == null || getClass() != obj.getClass()) {
98+
return false;
99+
}
100+
ClpColumnHandle other = (ClpColumnHandle) obj;
101+
return Objects.equals(this.columnName, other.columnName) &&
102+
Objects.equals(this.columnType, other.columnType);
103+
}
104+
105+
@Override
106+
public String toString()
107+
{
108+
return toStringHelper(this)
109+
.add("columnName", columnName)
110+
.add("columnType", columnType)
111+
.add("nullable", nullable)
112+
.toString();
113+
}
114+
}

0 commit comments

Comments
 (0)