-
Notifications
You must be signed in to change notification settings - Fork 37
feat: metadata access support for table #111
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
base: main
Are you sure you want to change the base?
Conversation
fc2ca57
to
6a26f30
Compare
src/iceberg/table.h
Outdated
/// \brief Return the schema for this table | ||
virtual const std::shared_ptr<Schema>& schema() const = 0; | ||
/// \brief Return the schema for this table, return NotFoundError if not found | ||
virtual Result<std::shared_ptr<Schema>> schema() const = 0; |
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.
virtual Result<std::shared_ptr<Schema>> schema() const = 0; | |
virtual Result<std::shared_ptr<Schema>> Schema() const = 0; |
These functions are no longer trivial accessors. We need to rename them with capitalized initial.
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 method name schema will conflicts with the Schema object name, and since this is actually a lazy getter, I think it can be treated as an accessor.
src/iceberg/table.h
Outdated
/// \brief Return the partition spec for this table | ||
virtual const std::shared_ptr<PartitionSpec>& spec() const = 0; | ||
/// \brief Return the partition spec for this table, return NotFoundError if not found | ||
virtual Result<std::shared_ptr<PartitionSpec>> spec() const = 0; |
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.
virtual Result<std::shared_ptr<PartitionSpec>> spec() const = 0; | |
virtual Result<std::shared_ptr<PartitionSpec>> Spec() const = 0; |
src/iceberg/table.h
Outdated
/// \brief Return the sort order for this table | ||
virtual const std::shared_ptr<SortOrder>& sort_order() const = 0; | ||
/// \brief Return the sort order for this table, return NotFoundError if not found | ||
virtual Result<std::shared_ptr<SortOrder>> sort_order() const = 0; |
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.
virtual Result<std::shared_ptr<SortOrder>> sort_order() const = 0; | |
virtual Result<std::shared_ptr<SortOrder>> SortOrder() const = 0; |
src/iceberg/table.h
Outdated
/// \brief Return the table's current snapshot | ||
virtual const std::shared_ptr<Snapshot>& current_snapshot() const = 0; | ||
/// \brief Return the table's current snapshot, or NotFoundError if not found | ||
virtual Result<std::shared_ptr<Snapshot>> current_snapshot() const = 0; |
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.
virtual Result<std::shared_ptr<Snapshot>> current_snapshot() const = 0; | |
virtual Result<std::shared_ptr<Snapshot>> CurrentSnapshot() const = 0; |
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.
I think there are still issues to address. Please also rebase this PR on the latest main branch to resolve the conflict.
src/iceberg/table.cc
Outdated
BaseTable::BaseTable(std::string name, std::shared_ptr<TableMetadata> metadata) | ||
: name_(std::move(name)), metadata_(std::move(metadata)) { | ||
if (!metadata_) { | ||
throw std::invalid_argument("Table metadata cannot be null"); |
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.
This is not resolved yet.
src/iceberg/table.cc
Outdated
void BaseTable::InitSchema() const { | ||
for (const auto& schema : metadata_->schemas) { | ||
if (schema->schema_id()) { | ||
schemas_map_.emplace(schema->schema_id().value(), 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.
I think these changes are still required
50c93a4
to
6aef4b4
Compare
5304adf
to
345355a
Compare
src/iceberg/table.cc
Outdated
} | ||
|
||
const std::shared_ptr<PartitionSpec>& Table::spec() const { | ||
std::call_once(init_partition_spec_once_, [this]() { |
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.
I'd suggest to follow similar implementation as Table::schema()
. In this function, we can cache and return PartitionSpec::Unpartitioned()
when missing.
src/iceberg/table.h
Outdated
/// \brief Return the table's current snapshot | ||
virtual const std::shared_ptr<Snapshot>& current_snapshot() const = 0; | ||
/// \brief Return the table's current snapshot, return null if not found | ||
std::shared_ptr<Snapshot> current_snapshot() const; |
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.
std::shared_ptr<Snapshot> current_snapshot() const; | |
const std::shared_ptr<Snapshot>& current_snapshot() const; |
Every table should have at least one snapshot. I think we can safely return a reference.
src/iceberg/table.cc
Outdated
} | ||
|
||
const std::unordered_map<int32_t, std::shared_ptr<Schema>>& Table::schemas() const { | ||
std::call_once(init_schemas_once_, [this]() { |
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.
What about removing the once flag and use std::shared_ptr<std::unordered_map<int32_t, std::shared_ptr<Schema>>>
instead?
No description provided.