-
Notifications
You must be signed in to change notification settings - Fork 48
feat(blob): support blob-desc/blob-view config parsing, schema validation and BlobFileContext #291
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
24b36e8
feat(blob): support blob-desc/blob-view config parsing, schema valida…
lxy-9602 8eafa32
Merge branch 'main' into blob-desc
lxy-9602 0b34339
fix copilot
lxy-9602 df1dead
fix fallback key
lxy-9602 08f6896
Merge branch 'main' into blob-desc
lxy-9602 97f8169
fix clang
lxy-9602 1ba6c2e
Merge branch 'main' into blob-desc
lxy-9602 dae4c1e
Merge branch 'main' into blob-desc
lszskye 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| /* | ||
| * Copyright 2026-present Alibaba Inc. | ||
| * | ||
| * 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. | ||
| */ | ||
|
|
||
| #include "paimon/core/operation/blob_file_context.h" | ||
|
|
||
| #include <utility> | ||
|
|
||
| #include "arrow/type.h" | ||
| #include "paimon/common/data/blob_utils.h" | ||
| #include "paimon/core/core_options.h" | ||
|
|
||
| namespace paimon { | ||
|
|
||
| BlobFileContext::BlobFileContext(std::set<std::string> descriptor_fields, | ||
| std::set<std::string> view_fields, | ||
| std::set<std::string> inline_fields, | ||
| std::set<std::string> external_storage_fields, | ||
| std::set<std::string> blob_file_fields, | ||
| std::optional<std::string> external_storage_path) | ||
| : descriptor_fields_(std::move(descriptor_fields)), | ||
| view_fields_(std::move(view_fields)), | ||
| inline_fields_(std::move(inline_fields)), | ||
| external_storage_fields_(std::move(external_storage_fields)), | ||
| blob_file_fields_(std::move(blob_file_fields)), | ||
| external_storage_path_(std::move(external_storage_path)) {} | ||
|
|
||
| std::unique_ptr<BlobFileContext> BlobFileContext::Create( | ||
| const std::shared_ptr<arrow::Schema>& schema, const CoreOptions& options) { | ||
| // Check if there are any BLOB fields in the schema | ||
| bool has_blob = false; | ||
| for (int i = 0; i < schema->num_fields(); ++i) { | ||
| if (BlobUtils::IsBlobField(schema->field(i))) { | ||
| has_blob = true; | ||
| break; | ||
| } | ||
| } | ||
| if (!has_blob) { | ||
| return nullptr; | ||
| } | ||
|
|
||
| // Populate descriptor fields | ||
| std::set<std::string> descriptor_fields; | ||
| for (const auto& name : options.GetBlobDescriptorFields()) { | ||
| descriptor_fields.insert(name); | ||
| } | ||
|
|
||
| // Populate view fields | ||
| std::set<std::string> view_fields; | ||
| for (const auto& name : options.GetBlobViewFields()) { | ||
| view_fields.insert(name); | ||
| } | ||
|
|
||
| // Populate inline fields from options (descriptor ∪ view) | ||
| std::set<std::string> inline_fields; | ||
| for (const auto& name : options.GetBlobInlineFields()) { | ||
| inline_fields.insert(name); | ||
| } | ||
|
|
||
| // Populate external storage fields | ||
| std::set<std::string> external_storage_fields; | ||
| for (const auto& name : options.GetBlobExternalStorageFields()) { | ||
| external_storage_fields.insert(name); | ||
| } | ||
|
|
||
| // Populate external storage path | ||
| std::optional<std::string> external_storage_path = options.GetBlobExternalStoragePath(); | ||
|
|
||
| // Determine blob_file_fields: BLOB fields that are NOT inline | ||
| std::set<std::string> blob_file_fields; | ||
| for (int i = 0; i < schema->num_fields(); ++i) { | ||
| const auto& field = schema->field(i); | ||
| if (BlobUtils::IsBlobField(field) && inline_fields.count(field->name()) == 0) { | ||
| blob_file_fields.insert(field->name()); | ||
|
lxy-9602 marked this conversation as resolved.
lxy-9602 marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| return std::unique_ptr<BlobFileContext>( | ||
| new BlobFileContext(std::move(descriptor_fields), std::move(view_fields), | ||
| std::move(inline_fields), std::move(external_storage_fields), | ||
| std::move(blob_file_fields), std::move(external_storage_path))); | ||
|
lxy-9602 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| bool BlobFileContext::IsInlineField(const std::string& field_name) const { | ||
| return inline_fields_.count(field_name) > 0; | ||
| } | ||
|
|
||
| bool BlobFileContext::IsBlobFileField(const std::string& field_name) const { | ||
| return blob_file_fields_.count(field_name) > 0; | ||
| } | ||
|
|
||
| bool BlobFileContext::IsDescriptorField(const std::string& field_name) const { | ||
| return descriptor_fields_.count(field_name) > 0; | ||
| } | ||
|
|
||
| bool BlobFileContext::IsViewField(const std::string& field_name) const { | ||
| return view_fields_.count(field_name) > 0; | ||
| } | ||
|
|
||
| bool BlobFileContext::IsExternalStorageField(const std::string& field_name) const { | ||
| return external_storage_fields_.count(field_name) > 0; | ||
| } | ||
|
|
||
| bool BlobFileContext::RequireBlobFileWriter() const { | ||
| return !blob_file_fields_.empty(); | ||
| } | ||
|
|
||
| bool BlobFileContext::RequireExternalStorageWriter() const { | ||
| return !external_storage_fields_.empty(); | ||
| } | ||
|
|
||
| } // namespace paimon | ||
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.