Repository navigation
branch-4.1: [feature](external) support partition- and bucket-aware concurrent writes #66685
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
Merged
yiguolei
merged 11 commits into
apache:branch-4.1
from
suxiaogang223:codex/paimon-write-distribution
Aug 17, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c0899e3
[feature](external) support concurrent external table writes
suxiaogang223 b6011dc
Revert "[feature](external) support concurrent external table writes"
suxiaogang223 a783182
[feature](external) unify table sink write distribution
suxiaogang223 c22b20d
[feature](external) compose sink routing and writer assignment
suxiaogang223 d6e7385
[fix](iceberg) use column data type for transform validation
suxiaogang223 825b5e5
[feature](paimon) route fixed buckets to concurrent writers
suxiaogang223 225c327
[feature](paimon) support dynamic bucket concurrent writes
suxiaogang223 905dfa0
Refactor external writer partitioners
suxiaogang223 97af758
refine Paimon fixed-bucket write routing
suxiaogang223 a6e0197
[fix](external) address sink routing review issues
suxiaogang223 96415ff
[fix](paimon) fall back for defaulted route fields
suxiaogang223 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
be/src/exec/partitioner/external/external_partition_function_factory.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you 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. | ||
|
|
||
| #include "exec/partitioner/external/external_partition_function_factory.h" | ||
|
|
||
| #include "common/status.h" | ||
| #include "exec/partitioner/external/paimon_fixed_bucket_partition_function.h" | ||
| #include "format/transformer/iceberg_partition_function.h" | ||
|
|
||
| namespace doris { | ||
| #include "common/compile_check_begin.h" | ||
|
|
||
| namespace { | ||
| bool has_partition_transform_metadata(const TExternalTableSinkHashPartitionInfo& info) { | ||
| return info.__isset.partition_transforms; | ||
| } | ||
|
|
||
| bool has_paimon_metadata(const TExternalTableSinkHashPartitionInfo& info) { | ||
| return info.__isset.paimon_fixed_bucket_info; | ||
| } | ||
|
|
||
| Status create_direct_hash_function(const TExternalTableSinkHashPartitionInfo& info, | ||
| PartitionerBase::HashValType logical_partition_count, | ||
| ShuffleHashMethod hash_method, | ||
| const std::vector<TExpr>& partition_exprs, | ||
| std::unique_ptr<PartitionFunction>* partition_function) { | ||
| if (has_partition_transform_metadata(info) || has_paimon_metadata(info)) { | ||
| return Status::InvalidArgument("Direct external sink hash contains incompatible metadata"); | ||
| } | ||
| auto function = std::make_unique<HashPartitionFunction>(logical_partition_count, hash_method); | ||
| RETURN_IF_ERROR(function->init(partition_exprs)); | ||
| *partition_function = std::move(function); | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| Status create_iceberg_function(const TExternalTableSinkHashPartitionInfo& info, | ||
| PartitionerBase::HashValType logical_partition_count, | ||
| ShuffleHashMethod hash_method, | ||
| const std::vector<TExpr>& partition_exprs, | ||
| std::unique_ptr<PartitionFunction>* partition_function) { | ||
| if (has_paimon_metadata(info)) { | ||
| return Status::InvalidArgument( | ||
| "Iceberg external sink routing contains incompatible Paimon metadata"); | ||
| } | ||
| if (!info.__isset.partition_transforms) { | ||
| return Status::InvalidArgument("Iceberg external sink partition transforms are missing"); | ||
| } | ||
| if (info.partition_transforms.size() != partition_exprs.size()) { | ||
| return Status::InvalidArgument( | ||
| "External sink partition transform count {} does not match expression count {}", | ||
| info.partition_transforms.size(), partition_exprs.size()); | ||
| } | ||
| std::vector<TIcebergPartitionField> fields; | ||
| fields.reserve(partition_exprs.size()); | ||
| for (size_t index = 0; index < partition_exprs.size(); ++index) { | ||
| TIcebergPartitionField field; | ||
| field.__set_transform(info.partition_transforms[index]); | ||
| field.__set_source_expr(partition_exprs[index]); | ||
| fields.emplace_back(std::move(field)); | ||
| } | ||
| auto function = std::make_unique<IcebergInsertPartitionFunction>( | ||
| logical_partition_count, hash_method, std::vector<TExpr> {}, std::move(fields)); | ||
| RETURN_IF_ERROR(function->init({})); | ||
| *partition_function = std::move(function); | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| Status create_paimon_fixed_bucket_function(const TExternalTableSinkHashPartitionInfo& info, | ||
| PartitionerBase::HashValType logical_partition_count, | ||
| const std::vector<TExpr>& partition_exprs, | ||
| std::unique_ptr<PartitionFunction>* partition_function) { | ||
| if (!info.__isset.paimon_fixed_bucket_info) { | ||
| return Status::InvalidArgument("Paimon fixed-bucket routing metadata is missing"); | ||
| } | ||
| if (has_partition_transform_metadata(info)) { | ||
| return Status::InvalidArgument( | ||
| "Paimon fixed-bucket routing contains incompatible metadata"); | ||
| } | ||
| auto function = std::make_unique<PaimonFixedBucketPartitionFunction>( | ||
| logical_partition_count, info.paimon_fixed_bucket_info); | ||
| RETURN_IF_ERROR(function->init(partition_exprs)); | ||
| *partition_function = std::move(function); | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| Status create_external_partition_function(const TExternalTableSinkHashPartitionInfo& partition_info, | ||
| PartitionerBase::HashValType logical_partition_count, | ||
| ShuffleHashMethod hash_method, | ||
| const std::vector<TExpr>& partition_exprs, | ||
| std::unique_ptr<PartitionFunction>* partition_function) { | ||
| if (partition_function == nullptr) { | ||
| return Status::InvalidArgument("External partition function output is null"); | ||
| } | ||
| switch (partition_info.algorithm) { | ||
| case TExternalTableSinkHashAlgorithm::DIRECT_HASH: | ||
| return create_direct_hash_function(partition_info, logical_partition_count, hash_method, | ||
| partition_exprs, partition_function); | ||
| case TExternalTableSinkHashAlgorithm::ICEBERG_TRANSFORM: | ||
| return create_iceberg_function(partition_info, logical_partition_count, hash_method, | ||
| partition_exprs, partition_function); | ||
| case TExternalTableSinkHashAlgorithm::PAIMON_FIXED_BUCKET: | ||
| return create_paimon_fixed_bucket_function(partition_info, logical_partition_count, | ||
| partition_exprs, partition_function); | ||
| default: | ||
| return Status::InvalidArgument("Unsupported external sink hash algorithm {}", | ||
| static_cast<int>(partition_info.algorithm)); | ||
| } | ||
| } | ||
|
|
||
| #include "common/compile_check_end.h" | ||
| } // namespace doris |
38 changes: 38 additions & 0 deletions
38
be/src/exec/partitioner/external/external_partition_function_factory.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you 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. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <gen_cpp/Partitions_types.h> | ||
|
|
||
| #include <memory> | ||
| #include <vector> | ||
|
|
||
| #include "exec/partitioner/partitioner.h" | ||
|
|
||
| namespace doris { | ||
| #include "common/compile_check_begin.h" | ||
|
|
||
| // Validates connector-specific routing metadata and creates the matching logical partition | ||
| // function. Writer assignment remains the responsibility of ExternalTableSinkHashPartitioner. | ||
| Status create_external_partition_function(const TExternalTableSinkHashPartitionInfo& partition_info, | ||
| PartitionerBase::HashValType logical_partition_count, | ||
| ShuffleHashMethod hash_method, | ||
| const std::vector<TExpr>& partition_exprs, | ||
| std::unique_ptr<PartitionFunction>* partition_function); | ||
|
|
||
| #include "common/compile_check_end.h" | ||
| } // namespace doris |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.