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

Add ConnectorDeleteTableHandle to ConnectorProtocol #24721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -25,5 +25,6 @@ using HiveConnectorProtocol = ConnectorProtocolTemplate<
HiveSplit,
HivePartitioningHandle,
HiveTransactionHandle,
HiveMetadataUpdateHandle>;
HiveMetadataUpdateHandle,
NotImplemented>;
} // namespace facebook::presto::protocol::hive
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ using IcebergConnectorProtocol = ConnectorProtocolTemplate<
IcebergSplit,
NotImplemented,
hive::HiveTransactionHandle,
NotImplemented,
NotImplemented>;

} // namespace facebook::presto::protocol::iceberg
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,33 @@ void from_json(const json& j, PrestoIcebergPartitionSpec& p) {
}
} // namespace facebook::presto::protocol::iceberg
namespace facebook::presto::protocol::iceberg {

void to_json(json& j, const SortField& p) {
j = json::object();
to_json_key(
j,
"sourceColumnId",
p.sourceColumnId,
"SortField",
"int",
"sourceColumnId");
to_json_key(
j, "sortOrder", p.sortOrder, "SortField", "SortOrder", "sortOrder");
}

void from_json(const json& j, SortField& p) {
from_json_key(
j,
"sourceColumnId",
p.sourceColumnId,
"SortField",
"int",
"sourceColumnId");
from_json_key(
j, "sortOrder", p.sortOrder, "SortField", "SortOrder", "sortOrder");
}
} // namespace facebook::presto::protocol::iceberg
namespace facebook::presto::protocol::iceberg {
IcebergInsertTableHandle::IcebergInsertTableHandle() noexcept {
_type = "hive-iceberg";
}
Expand Down Expand Up @@ -728,6 +755,13 @@ void to_json(json& j, const IcebergInsertTableHandle& p) {
"IcebergInsertTableHandle",
"Map<String, String>",
"storageProperties");
to_json_key(
j,
"sortOrder",
p.sortOrder,
"IcebergInsertTableHandle",
"List<SortField>",
"sortOrder");
}

void from_json(const json& j, IcebergInsertTableHandle& p) {
Expand Down Expand Up @@ -795,6 +829,13 @@ void from_json(const json& j, IcebergInsertTableHandle& p) {
"IcebergInsertTableHandle",
"Map<String, String>",
"storageProperties");
from_json_key(
j,
"sortOrder",
p.sortOrder,
"IcebergInsertTableHandle",
"List<SortField>",
"sortOrder");
}
} // namespace facebook::presto::protocol::iceberg
namespace facebook::presto::protocol::iceberg {
Expand Down Expand Up @@ -868,6 +909,13 @@ void to_json(json& j, const IcebergOutputTableHandle& p) {
"IcebergOutputTableHandle",
"Map<String, String>",
"storageProperties");
to_json_key(
j,
"sortOrder",
p.sortOrder,
"IcebergOutputTableHandle",
"List<SortField>",
"sortOrder");
}

void from_json(const json& j, IcebergOutputTableHandle& p) {
Expand Down Expand Up @@ -935,6 +983,13 @@ void from_json(const json& j, IcebergOutputTableHandle& p) {
"IcebergOutputTableHandle",
"Map<String, String>",
"storageProperties");
from_json_key(
j,
"sortOrder",
p.sortOrder,
"IcebergOutputTableHandle",
"List<SortField>",
"sortOrder");
}
} // namespace facebook::presto::protocol::iceberg
namespace facebook::presto::protocol::iceberg {
Expand Down Expand Up @@ -1151,6 +1206,20 @@ void to_json(json& j, const IcebergTableHandle& p) {
"IcebergTableHandle",
"List<Integer>",
"equalityFieldIds");
to_json_key(
j,
"sortOrder",
p.sortOrder,
"IcebergTableHandle",
"List<SortField>",
"sortOrder");
to_json_key(
j,
"updatedColumns",
p.updatedColumns,
"IcebergTableHandle",
"List<IcebergColumnHandle>",
"updatedColumns");
}

void from_json(const json& j, IcebergTableHandle& p) {
Expand Down Expand Up @@ -1211,6 +1280,20 @@ void from_json(const json& j, IcebergTableHandle& p) {
"IcebergTableHandle",
"List<Integer>",
"equalityFieldIds");
from_json_key(
j,
"sortOrder",
p.sortOrder,
"IcebergTableHandle",
"List<SortField>",
"sortOrder");
from_json_key(
j,
"updatedColumns",
p.updatedColumns,
"IcebergTableHandle",
"List<IcebergColumnHandle>",
"updatedColumns");
}
} // namespace facebook::presto::protocol::iceberg
namespace facebook::presto::protocol::iceberg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ struct PrestoIcebergPartitionSpec {
void to_json(json& j, const PrestoIcebergPartitionSpec& p);
void from_json(const json& j, PrestoIcebergPartitionSpec& p);
} // namespace facebook::presto::protocol::iceberg
namespace facebook::presto::protocol::iceberg {
struct SortField {
int sourceColumnId = {};
SortOrder sortOrder = {};
};
void to_json(json& j, const SortField& p);
void from_json(const json& j, SortField& p);
} // namespace facebook::presto::protocol::iceberg
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -201,6 +209,7 @@ struct IcebergInsertTableHandle : public ConnectorInsertTableHandle {
FileFormat fileFormat = {};
hive::HiveCompressionCodec compressionCodec = {};
Map<String, String> storageProperties = {};
List<SortField> sortOrder = {};

IcebergInsertTableHandle() noexcept;
};
Expand Down Expand Up @@ -235,6 +244,7 @@ struct IcebergOutputTableHandle : public ConnectorOutputTableHandle {
FileFormat fileFormat = {};
hive::HiveCompressionCodec compressionCodec = {};
Map<String, String> storageProperties = {};
List<SortField> sortOrder = {};

IcebergOutputTableHandle() noexcept;
};
Expand Down Expand Up @@ -289,6 +299,8 @@ struct IcebergTableHandle : public ConnectorTableHandle {
std::shared_ptr<String> tableSchemaJson = {};
std::shared_ptr<List<Integer>> partitionFieldIds = {};
std::shared_ptr<List<Integer>> equalityFieldIds = {};
List<SortField> sortOrder = {};
List<IcebergColumnHandle> updatedColumns = {};

IcebergTableHandle() noexcept;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ JavaClasses:
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/delete/DeleteFile.java
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/changelog/ChangelogOperation.java
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/changelog/ChangelogSplitInfo.java
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/SortField.java

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct IcebergInsertTableHandle : public ConnectorInsertTableHandle {
FileFormat fileFormat = {};
hive::HiveCompressionCodec compressionCodec = {};
Map<String, String> storageProperties = {};
List<SortField> sortOrder = {};

IcebergInsertTableHandle() noexcept;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct IcebergOutputTableHandle : public ConnectorOutputTableHandle {
FileFormat fileFormat = {};
hive::HiveCompressionCodec compressionCodec = {};
Map<String, String> storageProperties = {};
List<SortField> sortOrder = {};

IcebergOutputTableHandle() noexcept;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ class ConnectorProtocol {
virtual void from_json(
const json& j,
std::shared_ptr<ConnectorMetadataUpdateHandle>& p) const = 0;

virtual void to_json(
json& j,
const std::shared_ptr<ConnectorDeleteTableHandle>& p) const = 0;
virtual void from_json(
const json& j,
std::shared_ptr<ConnectorDeleteTableHandle>& p) const = 0;
};

namespace {
Expand All @@ -104,7 +111,8 @@ template <
typename ConnectorSplitType = NotImplemented,
typename ConnectorPartitioningHandleType = NotImplemented,
typename ConnectorTransactionHandleType = NotImplemented,
typename ConnectorMetadataUpdateHandleType = NotImplemented>
typename ConnectorMetadataUpdateHandleType = NotImplemented,
typename ConnectorDeleteTableHandleType = NotImplemented>
class ConnectorProtocolTemplate final : public ConnectorProtocol {
public:
void to_json(json& j, const std::shared_ptr<ConnectorTableHandle>& p)
Expand Down Expand Up @@ -186,6 +194,16 @@ class ConnectorProtocolTemplate final : public ConnectorProtocol {
from_json_template<ConnectorMetadataUpdateHandleType>(j, p);
}

void to_json(json& j, const std::shared_ptr<ConnectorDeleteTableHandle>& p)
const final {
to_json_template<ConnectorDeleteTableHandleType>(j, p);
}
void from_json(
const json& j,
std::shared_ptr<ConnectorDeleteTableHandle>& p) const final {
from_json_template<ConnectorDeleteTableHandleType>(j, p);
}

private:
template <typename DERIVED, typename BASE>
static void to_json_template(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3251,6 +3251,91 @@ void from_json(const json& j, CreateHandle& p) {
"schemaTableName");
}
} // namespace facebook::presto::protocol
/*
* 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.
*/
namespace facebook::presto::protocol {
void to_json(json& j, const std::shared_ptr<ConnectorDeleteTableHandle>& p) {
if (p == nullptr) {
return;
}
String type = p->_type;
getConnectorProtocol(type).to_json(j, p);
}

void from_json(const json& j, std::shared_ptr<ConnectorDeleteTableHandle>& p) {
String type;
try {
type = p->getSubclassKey(j);
} catch (json::parse_error& e) {
throw ParseError(
std::string(e.what()) +
" ConnectorDeleteTableHandle ConnectorDeleteTableHandle");
}
getConnectorProtocol(type).from_json(j, p);
}
} // namespace facebook::presto::protocol
namespace facebook::presto::protocol {

void to_json(json& j, const DeleteTableHandle& p) {
j = json::object();
to_json_key(
j,
"connectorId",
p.connectorId,
"DeleteTableHandle",
"ConnectorId",
"connectorId");
to_json_key(
j,
"transactionHandle",
p.transactionHandle,
"DeleteTableHandle",
"ConnectorTransactionHandle",
"transactionHandle");
to_json_key(
j,
"connectorHandle",
p.connectorHandle,
"DeleteTableHandle",
"ConnectorDeleteTableHandle",
"connectorHandle");
}

void from_json(const json& j, DeleteTableHandle& p) {
from_json_key(
j,
"connectorId",
p.connectorId,
"DeleteTableHandle",
"ConnectorId",
"connectorId");
from_json_key(
j,
"transactionHandle",
p.transactionHandle,
"DeleteTableHandle",
"ConnectorTransactionHandle",
"transactionHandle");
from_json_key(
j,
"connectorHandle",
p.connectorHandle,
"DeleteTableHandle",
"ConnectorDeleteTableHandle",
"connectorHandle");
}
} // namespace facebook::presto::protocol
namespace facebook::presto::protocol {
DeleteHandle::DeleteHandle() noexcept {
_type = "DeleteHandle";
Expand All @@ -3259,7 +3344,8 @@ DeleteHandle::DeleteHandle() noexcept {
void to_json(json& j, const DeleteHandle& p) {
j = json::object();
j["@type"] = "DeleteHandle";
to_json_key(j, "handle", p.handle, "DeleteHandle", "TableHandle", "handle");
to_json_key(
j, "handle", p.handle, "DeleteHandle", "DeleteTableHandle", "handle");
to_json_key(
j,
"schemaTableName",
Expand All @@ -3271,7 +3357,8 @@ void to_json(json& j, const DeleteHandle& p) {

void from_json(const json& j, DeleteHandle& p) {
p._type = j["@type"];
from_json_key(j, "handle", p.handle, "DeleteHandle", "TableHandle", "handle");
from_json_key(
j, "handle", p.handle, "DeleteHandle", "DeleteTableHandle", "handle");
from_json_key(
j,
"schemaTableName",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ void to_json(json& j, const std::shared_ptr<ConnectorOutputTableHandle>& p);
void from_json(const json& j, std::shared_ptr<ConnectorOutputTableHandle>& p);
} // namespace facebook::presto::protocol
namespace facebook::presto::protocol {
struct ConnectorDeleteTableHandle : public JsonEncodedSubclass {};
void to_json(json& j, const std::shared_ptr<ConnectorDeleteTableHandle>& p);
void from_json(const json& j, std::shared_ptr<ConnectorDeleteTableHandle>& p);
} // namespace facebook::presto::protocol
namespace facebook::presto::protocol {
struct InputDistribution : public JsonEncodedSubclass {};
void to_json(json& j, const std::shared_ptr<InputDistribution>& p);
void from_json(const json& j, std::shared_ptr<InputDistribution>& p);
Expand Down Expand Up @@ -1026,8 +1031,17 @@ void to_json(json& j, const CreateHandle& p);
void from_json(const json& j, CreateHandle& p);
} // namespace facebook::presto::protocol
namespace facebook::presto::protocol {
struct DeleteTableHandle {
ConnectorId connectorId = {};
std::shared_ptr<ConnectorTransactionHandle> transactionHandle = {};
std::shared_ptr<ConnectorDeleteTableHandle> connectorHandle = {};
};
void to_json(json& j, const DeleteTableHandle& p);
void from_json(const json& j, DeleteTableHandle& p);
} // namespace facebook::presto::protocol
namespace facebook::presto::protocol {
struct DeleteHandle : public ExecutionWriterTarget {
TableHandle handle = {};
DeleteTableHandle handle = {};
SchemaTableName schemaTableName = {};

DeleteHandle() noexcept;
Expand Down
Loading
Loading