Skip to content
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 @@ -79,6 +79,14 @@ class PrestoToVeloxConnector {
return {};
}

[[nodiscard]] virtual std::unique_ptr<
velox::connector::ConnectorInsertTableHandle>
toVeloxInsertTableHandle(
const protocol::DeleteHandle* deleteHandle,
const TypeParser& typeParser) const {
return {};
}

[[nodiscard]] std::unique_ptr<velox::core::PartitionFunctionSpec>
createVeloxPartitionFunctionSpec(
const protocol::ConnectorPartitioningHandle* partitioningHandle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,64 @@ VeloxQueryPlanConverterBase::toVeloxQueryPlan(
sourceVeloxPlan);
}

std::shared_ptr<const core::TableWriteNode>
VeloxQueryPlanConverterBase::toVeloxQueryPlan(
const std::shared_ptr<const protocol::DeleteNode>& node,
const std::shared_ptr<protocol::TableWriteInfo>& tableWriteInfo,
const protocol::TaskId& taskId) {
std::string connectorId;
std::shared_ptr<connector::ConnectorInsertTableHandle> connectorInsertHandle;
if (
auto deleteHandle = std::dynamic_pointer_cast<protocol::DeleteHandle>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit maybe abstract a toConnectorDeleteTableHandle method like other functions (e.g. toConnectorTableHandle) in this file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look! I added a for toVeloxQueryPlan(DeleteNode). It was a bit complex due to not having an existing connector actually implementing the delete portions, but I think I've successfully mocked up what was needed.

tableWriteInfo->writerTarget)) {
connectorId = deleteHandle->handle.connectorId;
auto& connector =
getPrestoToVeloxConnector(deleteHandle->handle.connectorHandle->_type);
auto veloxHandle =
connector.toVeloxInsertTableHandle(deleteHandle.get(), typeParser_);
connectorInsertHandle = std::shared_ptr(std::move(veloxHandle));
}

if (!connectorInsertHandle) {
VELOX_UNSUPPORTED(
"Unsupported table writer handle: {}",
toJsonString(tableWriteInfo->writerTarget));
}

auto insertTableHandle = std::make_shared<core::InsertTableHandle>(
connectorId, connectorInsertHandle);

const auto outputType = toRowType(
generateOutputVariables(node->outputVariables, nullptr),
typeParser_);

const auto sourceVeloxPlan =
toVeloxQueryPlan(node->source, tableWriteInfo, taskId);

// get columns and partition keys from InputDistribution
auto inputDistribution = std::dynamic_pointer_cast<protocol::BaseInputDistribution>(
node->inputDistribution);

if (!inputDistribution) {
VELOX_UNSUPPORTED(
"Unsupported input distribution type: {}",
toJsonString(node->inputDistribution));
}

auto inputColumns = toRowType(inputDistribution->inputVariables, typeParser_);

return std::make_shared<core::TableWriteNode>(
node->id,
inputColumns,
inputColumns->names(),
nullptr, // aggregationNode
std::move(insertTableHandle),
true, // delete only supported on partitioned tables
outputType,
getCommitStrategy(),
sourceVeloxPlan);
}

std::shared_ptr<const core::TableWriteMergeNode>
VeloxQueryPlanConverterBase::toVeloxQueryPlan(
const std::shared_ptr<const protocol::TableWriterMergeNode>& node,
Expand Down Expand Up @@ -1696,6 +1754,10 @@ core::PlanNodePtr VeloxQueryPlanConverterBase::toVeloxQueryPlan(
std::dynamic_pointer_cast<const protocol::TableWriterNode>(node)) {
return toVeloxQueryPlan(tableWriter, tableWriteInfo, taskId);
}
if (auto deleteNode =
std::dynamic_pointer_cast<const protocol::DeleteNode>(node)) {
return toVeloxQueryPlan(deleteNode, tableWriteInfo, taskId);
}
if (auto tableWriteMerger =
std::dynamic_pointer_cast<const protocol::TableWriterMergeNode>(
node)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ class VeloxQueryPlanConverterBase {
const std::shared_ptr<protocol::TableWriteInfo>& tableWriteInfo,
const protocol::TaskId& taskId);

std::shared_ptr<const velox::core::TableWriteNode> toVeloxQueryPlan(
const std::shared_ptr<const protocol::DeleteNode>& node,
const std::shared_ptr<protocol::TableWriteInfo>& tableWriteInfo,
const protocol::TaskId& taskId);

std::shared_ptr<const velox::core::TableWriteMergeNode> toVeloxQueryPlan(
const std::shared_ptr<const protocol::TableWriterMergeNode>& node,
const std::shared_ptr<protocol::TableWriteInfo>& tableWriteInfo,
Expand Down