Skip to content
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

Refactor Java Hive and Iceberg Connector for Prestissimo Iceberg Connector #21662

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,66 @@
*/
package com.facebook.presto.hive;

import com.facebook.presto.common.Subfield;
import com.facebook.presto.spi.ColumnHandle;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public interface BaseHiveColumnHandle
extends ColumnHandle
import java.util.List;
import java.util.Optional;

import static java.util.Objects.requireNonNull;

public class BaseHiveColumnHandle
implements ColumnHandle
{
String getName();
public enum ColumnType
{
PARTITION_KEY,
REGULAR,
SYNTHESIZED,
AGGREGATED,
}

private final String name;
private final Optional<String> comment;
private final ColumnType columnType;
private final List<Subfield> requiredSubfields;

@JsonCreator
public BaseHiveColumnHandle(
@JsonProperty("name") String name,
@JsonProperty("comment") Optional<String> comment,
@JsonProperty("columnType") ColumnType columnType,
@JsonProperty("requiredSubfields") List<Subfield> requiredSubfields)
{
this.name = requireNonNull(name, "name is null");
this.comment = requireNonNull(comment, "comment is null");
this.columnType = requireNonNull(columnType, "columnType is null");
this.requiredSubfields = requireNonNull(requiredSubfields, "requiredSubfields is null");
}

@JsonProperty
public String getName()
{
return name;
}

@JsonProperty
public Optional<String> getComment()
{
return comment;
}

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

@JsonProperty
public List<Subfield> getRequiredSubfields()
{
return requiredSubfields;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.hive;

import com.facebook.presto.spi.ConnectorTableHandle;
import com.facebook.presto.spi.SchemaTableName;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import static java.util.Objects.requireNonNull;

public class BaseHiveTableHandle
implements ConnectorTableHandle
{
private final String schemaName;
private final String tableName;

@JsonCreator
public BaseHiveTableHandle(
@JsonProperty("schemaName") String schemaName,
@JsonProperty("tableName") String tableName)
{
this.schemaName = requireNonNull(schemaName, "schemaName is null");
this.tableName = requireNonNull(tableName, "tableName is null");
}

@JsonProperty
public String getSchemaName()
{
return schemaName;
}

@JsonProperty
public String getTableName()
{
return tableName;
}

public SchemaTableName getSchemaTableName()
{
return new SchemaTableName(schemaName, tableName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableList;

import java.util.List;
import java.util.Optional;
Expand All @@ -30,6 +31,7 @@
public class BaseHiveTableLayoutHandle
implements ConnectorTableLayoutHandle
{
private final List<BaseHiveColumnHandle> partitionColumns;
private final TupleDomain<Subfield> domainPredicate;
private final RowExpression remainingPredicate;
private final boolean pushdownFilterEnabled;
Expand All @@ -40,19 +42,27 @@ public class BaseHiveTableLayoutHandle

@JsonCreator
public BaseHiveTableLayoutHandle(
@JsonProperty("partitionColumns") List<BaseHiveColumnHandle> partitionColumns,
@JsonProperty("domainPredicate") TupleDomain<Subfield> domainPredicate,
@JsonProperty("remainingPredicate") RowExpression remainingPredicate,
@JsonProperty("pushdownFilterEnabled") boolean pushdownFilterEnabled,
@JsonProperty("partitionColumnPredicate") TupleDomain<ColumnHandle> partitionColumnPredicate,
@JsonProperty("partitions") Optional<List<HivePartition>> partitions)
{
this.partitionColumns = ImmutableList.copyOf(requireNonNull(partitionColumns, "partitionColumns is null"));
this.domainPredicate = requireNonNull(domainPredicate, "domainPredicate is null");
this.remainingPredicate = requireNonNull(remainingPredicate, "remainingPredicate is null");
this.pushdownFilterEnabled = pushdownFilterEnabled;
this.partitionColumnPredicate = requireNonNull(partitionColumnPredicate, "partitionColumnPredicate is null");
this.partitions = requireNonNull(partitions, "partitions is null");
}

@JsonProperty
public List<BaseHiveColumnHandle> getPartitionColumns()
{
return partitionColumns;
}

@JsonProperty
public TupleDomain<Subfield> getDomainPredicate()
{
Expand Down
5 changes: 5 additions & 0 deletions presto-hive-hadoop2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<artifactId>presto-hive</artifactId>
</dependency>

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

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-hive-metastore</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import static com.facebook.airlift.testing.Assertions.assertEqualsIgnoreOrder;
import static com.facebook.presto.common.type.BigintType.BIGINT;
import static com.facebook.presto.hive.HiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.BaseHiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.HiveType.HIVE_LONG;

public class TestHiveFileSystemS3SelectCsvPushdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.Optional;

import static com.facebook.airlift.testing.Assertions.assertEqualsIgnoreOrder;
import static com.facebook.presto.hive.HiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.BaseHiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.HiveFileSystemTestUtils.newSession;
import static com.facebook.presto.hive.HiveType.HIVE_LONG;
import static com.facebook.presto.hive.s3select.S3SelectTestHelper.expectedResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import static com.facebook.airlift.testing.Assertions.assertEqualsIgnoreOrder;
import static com.facebook.presto.common.type.BigintType.BIGINT;
import static com.facebook.presto.hive.HiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.BaseHiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.HiveFileSystemTestUtils.filterTable;
import static com.facebook.presto.hive.HiveFileSystemTestUtils.newSession;
import static com.facebook.presto.hive.HiveFileSystemTestUtils.readTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.Optional;

import static com.facebook.airlift.testing.Assertions.assertEqualsIgnoreOrder;
import static com.facebook.presto.hive.HiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.BaseHiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.HiveFileSystemTestUtils.newSession;
import static com.facebook.presto.hive.HiveType.HIVE_LONG;
import static com.facebook.presto.hive.s3select.S3SelectTestHelper.expectedResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.facebook.presto.hive;

import com.facebook.presto.spi.ConnectorTableHandle;
import com.facebook.presto.spi.SchemaTableName;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

Expand All @@ -26,11 +24,8 @@
import static java.util.Objects.requireNonNull;

public class HiveTableHandle
implements ConnectorTableHandle
extends BaseHiveTableHandle
{
private final String schemaName;
private final String tableName;

private final Optional<List<List<String>>> analyzePartitionValues;

@JsonCreator
Expand All @@ -39,8 +34,8 @@ public HiveTableHandle(
@JsonProperty("tableName") String tableName,
@JsonProperty("analyzePartitionValues") Optional<List<List<String>>> analyzePartitionValues)
{
this.schemaName = requireNonNull(schemaName, "schemaName is null");
this.tableName = requireNonNull(tableName, "tableName is null");
super(schemaName, tableName);

this.analyzePartitionValues = requireNonNull(analyzePartitionValues, "analyzePartitionValues is null");
}

Expand All @@ -51,19 +46,7 @@ public HiveTableHandle(String schemaName, String tableName)

public HiveTableHandle withAnalyzePartitionValues(Optional<List<List<String>>> analyzePartitionValues)
{
return new HiveTableHandle(schemaName, tableName, analyzePartitionValues);
}

@JsonProperty
public String getSchemaName()
{
return schemaName;
}

@JsonProperty
public String getTableName()
{
return tableName;
return new HiveTableHandle(getSchemaName(), getTableName(), analyzePartitionValues);
}

@JsonProperty
Expand All @@ -72,11 +55,6 @@ public Optional<List<List<String>>> getAnalyzePartitionValues()
return analyzePartitionValues;
}

public SchemaTableName getSchemaTableName()
{
return new SchemaTableName(schemaName, tableName);
}

@Override
public boolean equals(Object o)
{
Expand All @@ -88,23 +66,23 @@ public boolean equals(Object o)
}
HiveTableHandle that = (HiveTableHandle) o;
// Do not include analyzePartitionValues in hashCode and equals comparison
return Objects.equals(schemaName, that.schemaName) &&
Objects.equals(tableName, that.tableName);
return Objects.equals(getSchemaName(), that.getSchemaName()) &&
Objects.equals(getTableName(), that.getTableName());
}

@Override
public int hashCode()
{
// Do not include analyzePartitionValues in hashCode and equals comparison
return Objects.hash(schemaName, tableName);
return Objects.hash(getSchemaName(), getTableName());
}

@Override
public String toString()
{
return toStringHelper(this)
.add("schemaName", schemaName)
.add("tableName", tableName)
.add("schemaName", getSchemaName())
.add("tableName", getTableName())
.add("analyzePartitionValues", analyzePartitionValues)
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import static com.facebook.presto.common.type.VarbinaryType.VARBINARY;
import static com.facebook.presto.common.type.Varchars.isVarcharType;
import static com.facebook.presto.common.type.Varchars.truncateToLength;
import static com.facebook.presto.hive.HiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.BaseHiveColumnHandle.ColumnType.REGULAR;
import static com.facebook.presto.hive.HiveErrorCode.HIVE_BAD_DATA;
import static com.facebook.presto.hive.HiveErrorCode.HIVE_CURSOR_ERROR;
import static com.facebook.presto.hive.HiveUtil.closeWithSuppression;
Expand Down
Loading
Loading