-
Notifications
You must be signed in to change notification settings - Fork 66
refactor: change PartitionSpec to be independent of Schema #299
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
Conversation
335a0da to
bb499ad
Compare
wgtmac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main feedback is that we need to keep the schema parameter because we eventually need it to create bound partition spec.
| /// \param[out] default_spec_id The default partition spec ID. | ||
| /// \param[out] partition_specs The list of partition specs. | ||
| Status ParsePartitionSpecs(const nlohmann::json& json, int8_t format_version, | ||
| const std::shared_ptr<Schema>& current_schema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, let's keep it.
src/iceberg/json_internal.cc
Outdated
| for (const auto& spec_json : spec_array) { | ||
| ICEBERG_ASSIGN_OR_RAISE(auto spec, | ||
| PartitionSpecFromJson(current_schema, spec_json)); | ||
| ICEBERG_ASSIGN_OR_RAISE(auto spec, PartitionSpecFromJson(spec_json)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| std::shared_ptr<Schema> schema) { | ||
| if (fields_.empty()) { | ||
| return nullptr; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation allows using partition_type_ cache based on tableschema_, but the given schema parameter may belong to a different schema version, which could lead to correctness issues.
Suggest adding schema_id to the cache key to ensure consistency.
such as:
std::unordered_map<int32_t, std::shared_ptr> partition_type_cache_;
a859eac to
f63808c
Compare
f63808c to
8455f61
Compare
zhjwpku
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
baafb89 to
eb0e134
Compare
schema_member fromPartitionSpec, MakingPartitionType()method require a Schema parameter instead of using the stored schema.table_schema_inManifestEntryAdapter.table_schemainmetadata_["schema"].