Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
<module>presto-base-arrow-flight</module>
<module>presto-function-server</module>
<module>presto-router-example-plugin-scheduler</module>
<module>presto-clp</module>
</modules>

<dependencyManagement>
Expand Down
128 changes: 128 additions & 0 deletions presto-clp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?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.293</version>
</parent>

<artifactId>presto-clp</artifactId>
<description>Presto - CLP Connector</description>
<packaging>presto-plugin</packaging>

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

<dependencies>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.facebook.airlift</groupId>
<artifactId>bootstrap</artifactId>
</dependency>

<dependency>
<groupId>com.facebook.airlift</groupId>
<artifactId>json</artifactId>
</dependency>

<dependency>
<groupId>com.facebook.airlift</groupId>
<artifactId>log</artifactId>
</dependency>

<dependency>
<groupId>com.facebook.airlift</groupId>
<artifactId>configuration</artifactId>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>

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

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

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>provided</scope>
</dependency>

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

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-common</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>units</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>slice</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-main-base</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-analyzer</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-parser</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* 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.plugin.clp;

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

import java.util.Objects;

import static com.google.common.base.MoreObjects.toStringHelper;

public class ClpColumnHandle
implements ColumnHandle
{
private final String columnName;
private final String originalColumnName;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private final String originalColumnName;
// The full field path for a field. When the field is not nested field it is the same as columnName
private final String originalColumnName;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about the polymorphism, not about nested

private final Type columnType;
private final boolean nullable;

@JsonCreator
public ClpColumnHandle(
@JsonProperty("columnName") String columnName,
@JsonProperty("originalColumnName") String originalColumnName,
@JsonProperty("columnType") Type columnType,
@JsonProperty("nullable") boolean nullable)
{
this.columnName = columnName;
this.originalColumnName = originalColumnName;
this.columnType = columnType;
this.nullable = nullable;
}
Comment on lines +34 to +45
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Enforce non-null invariants for handle fields

For consistency with other Presto handle implementations, validate all object references:

-import java.util.Objects;
+import java.util.Objects;
+import static java.util.Objects.requireNonNull;
 ...
         this.columnName = requireNonNull(columnName, "columnName is null");
         this.originalColumnName = requireNonNull(originalColumnName, "originalColumnName is null");
         this.columnType = requireNonNull(columnType, "columnType is null");

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpColumnHandle.java
around lines 34 to 45, the constructor parameters columnName,
originalColumnName, and columnType are not validated for null values. To enforce
non-null invariants consistent with other Presto handle implementations, add
explicit null checks for these parameters at the start of the constructor and
throw appropriate exceptions if any are null.


public ClpColumnHandle(String columnName, Type columnType, boolean nullable)
{
this(columnName, columnName, columnType, nullable);
}

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

@JsonProperty
public String getOriginalColumnName()
{
return originalColumnName;
}

@JsonProperty
public Type getColumnType()
{
return columnType;
}

@JsonProperty
public boolean isNullable()
{
return nullable;
}

public ColumnMetadata getColumnMetadata()
{
return ColumnMetadata.builder()
.setName(columnName)
.setType(columnType)
.setNullable(nullable)
.build();
}

@Override
public int hashCode()
{
return Objects.hash(columnName, originalColumnName, columnType, nullable);
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
ClpColumnHandle other = (ClpColumnHandle) obj;
return Objects.equals(this.columnName, other.columnName) &&
Objects.equals(this.originalColumnName, other.originalColumnName) &&
Objects.equals(this.columnType, other.columnType) &&
Objects.equals(this.nullable, other.nullable);
}

@Override
public String toString()
{
return toStringHelper(this)
.add("columnName", columnName)
.add("originalColumnName", originalColumnName)
.add("columnType", columnType)
.add("nullable", nullable)
.toString();
}
}
Loading
Loading