Skip to content

Commit

Permalink
recombine iceberg tablehandle and deletetablehandle, fix serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
shelton408 committed Feb 12, 2025
1 parent a69a5a0 commit 2e9f2cd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -860,40 +860,29 @@ public void truncateTable(ConnectorSession session, ConnectorTableHandle tableHa
public ConnectorDeleteTableHandle beginDelete(ConnectorSession session, ConnectorTableHandle tableHandle)
{
IcebergTableHandle handle = (IcebergTableHandle) tableHandle;
IcebergDeleteTableHandle deleteHandle = new IcebergDeleteTableHandle(
handle.getSchemaName(),
handle.getIcebergTableName(),
handle.isSnapshotSpecified(),
handle.getOutputPath(),
handle.getStorageProperties(),
handle.getTableSchemaJson(),
handle.getPartitionSpecId(),
handle.getEqualityFieldIds());
Table icebergTable = getIcebergTable(session, deleteHandle.getSchemaTableName());

if (deleteHandle.isSnapshotSpecified()) {
Table icebergTable = getIcebergTable(session, handle.getSchemaTableName());

if (handle.isSnapshotSpecified()) {
throw new PrestoException(NOT_SUPPORTED, "This connector do not allow delete data at specified snapshot");
}

int formatVersion = ((BaseTable) icebergTable).operations().current().formatVersion();
if (formatVersion < MIN_FORMAT_VERSION_FOR_DELETE) {
throw new PrestoException(NOT_SUPPORTED, format("This connector only supports delete where one or more partitions are deleted entirely for table versions older than %d", MIN_FORMAT_VERSION_FOR_DELETE));
}

if (getDeleteMode(icebergTable) == RowLevelOperationMode.COPY_ON_WRITE) {
throw new PrestoException(NOT_SUPPORTED, "This connector only supports delete where one or more partitions are deleted entirely. Configure delete_mode table property to allow row level deletions.");
}

validateTableMode(session, icebergTable);
transaction = icebergTable.newTransaction();

return deleteHandle;
return handle;
}

@Override
public void finishDelete(ConnectorSession session, ConnectorDeleteTableHandle tableHandle, Collection<Slice> fragments)
{
IcebergDeleteTableHandle handle = (IcebergDeleteTableHandle) tableHandle;
IcebergTableHandle handle = (IcebergTableHandle) tableHandle;
Table icebergTable = getIcebergTable(session, handle.getSchemaTableName());

RowDelta rowDelta = transaction.newRowDelta();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Class<? extends ConnectorInsertTableHandle> getInsertTableHandleClass()
@Override
public Class<? extends ConnectorDeleteTableHandle> getDeleteTableHandleClass()
{
return IcebergDeleteTableHandle.class;
return IcebergTableHandle.class;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package com.facebook.presto.iceberg;

import com.facebook.presto.hive.BaseHiveTableHandle;
import com.facebook.presto.spi.ConnectorDeleteTableHandle;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

Expand All @@ -26,6 +27,7 @@

public class IcebergTableHandle
extends BaseHiveTableHandle
implements ConnectorDeleteTableHandle
{
private final IcebergTableName icebergTableName;
private final boolean snapshotSpecified;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private <T> String getId(T handle, Function<MaterializedHandleResolver, Optional
catch (UnsupportedOperationException ignored) {
}
}
throw new IllegalArgumentException("No connector for handle: " + handle);
throw new IllegalArgumentException("No connector for handle: " + handle + " of type " + handle.getClass());
}

private <T> String getFunctionNamespaceId(T handle, Function<MaterializedFunctionHandleResolver, Optional<Class<? extends T>>> getter)
Expand Down

0 comments on commit 2e9f2cd

Please sign in to comment.