-
Notifications
You must be signed in to change notification settings - Fork 112
feat(inspect): add base metadata table interface #607
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
11 commits
Select commit
Hold shift + click to select a range
df05375
feat(inspect): Add base class for metadata table support
All-less 6c646e0
Update MetadataTable to inherit from StaticTable
All-less 484d0d5
Update build files to include MetadataTable
All-less 9edb8bc
Remove unused CreateSchema definitions
All-less 6737c3f
Update Metadata creation to return unique_ptr
All-less 6d2438e
Refactor MetadataTable to use separate TableMetadata and unified entr…
All-less e0a7d16
Fix wrong template parameter in MetadataTable::NewScan
All-less f8f7aea
Fix format errors in Meson and CMake build files
All-less 8188d1d
Add initializer names to SnapshotsTable and HistoryTable
All-less 18ebed7
Remove override keyword from GetSchema impl
All-less 92fe7fe
polish and simplify metadata table design
wgtmac 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # 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. | ||
|
|
||
| iceberg_install_all_headers(iceberg/inspect) |
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,62 @@ | ||
| /* | ||
| * 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 "iceberg/inspect/history_table.h" | ||
|
|
||
| #include <memory> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include "iceberg/schema.h" | ||
| #include "iceberg/schema_field.h" | ||
| #include "iceberg/table.h" | ||
| #include "iceberg/table_identifier.h" | ||
| #include "iceberg/type.h" | ||
|
|
||
| namespace iceberg { | ||
| namespace { | ||
|
|
||
| std::shared_ptr<Schema> MakeHistoryTableSchema() { | ||
| return std::make_shared<Schema>(std::vector<SchemaField>{ | ||
| SchemaField::MakeRequired(1, "made_current_at", timestamp_tz()), | ||
| SchemaField::MakeRequired(2, "snapshot_id", int64()), | ||
| SchemaField::MakeOptional(3, "parent_id", int64()), | ||
| SchemaField::MakeRequired(4, "is_current_ancestor", boolean())}); | ||
| } | ||
|
|
||
| TableIdentifier MakeHistoryTableName(const TableIdentifier& source_name) { | ||
| return TableIdentifier{.ns = source_name.ns, .name = source_name.name + ".history"}; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| HistoryTable::HistoryTable(std::shared_ptr<Table> table) | ||
| : MetadataTable(table, MakeHistoryTableName(table->name()), | ||
| MakeHistoryTableSchema()) {} | ||
|
|
||
| HistoryTable::~HistoryTable() = default; | ||
|
|
||
| Result<std::unique_ptr<HistoryTable>> HistoryTable::Make(std::shared_ptr<Table> table) { | ||
| if (table == nullptr) [[unlikely]] { | ||
| return InvalidArgument("Table cannot be null"); | ||
| } | ||
| return std::unique_ptr<HistoryTable>(new HistoryTable(std::move(table))); | ||
| } | ||
|
|
||
| } // namespace iceberg |
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,44 @@ | ||
| /* | ||
| * 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 <memory> | ||
|
|
||
| #include "iceberg/iceberg_export.h" | ||
| #include "iceberg/inspect/metadata_table.h" | ||
| #include "iceberg/result.h" | ||
| #include "iceberg/type_fwd.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| /// \brief History metadata table. | ||
| class ICEBERG_EXPORT HistoryTable : public MetadataTable { | ||
| public: | ||
| static Result<std::unique_ptr<HistoryTable>> Make(std::shared_ptr<Table> table); | ||
|
|
||
| ~HistoryTable() override; | ||
|
|
||
| Kind kind() const noexcept override { return Kind::kHistory; } | ||
|
|
||
| private: | ||
| explicit HistoryTable(std::shared_ptr<Table> table); | ||
| }; | ||
|
|
||
| } // namespace iceberg |
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,21 @@ | ||
| # 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. | ||
|
|
||
| install_headers( | ||
| ['history_table.h', 'metadata_table.h', 'snapshots_table.h'], | ||
| subdir: 'iceberg/inspect', | ||
| ) |
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,54 @@ | ||
| /* | ||
| * 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 "iceberg/inspect/metadata_table.h" | ||
|
|
||
| #include <memory> | ||
| #include <utility> | ||
|
|
||
| #include "iceberg/inspect/history_table.h" | ||
| #include "iceberg/inspect/snapshots_table.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| MetadataTable::MetadataTable(std::shared_ptr<Table> source_table, | ||
| TableIdentifier identifier, std::shared_ptr<Schema> schema) | ||
| : identifier_(std::move(identifier)), | ||
| schema_(std::move(schema)), | ||
| source_table_(std::move(source_table)) {} | ||
|
|
||
| MetadataTable::~MetadataTable() = default; | ||
|
|
||
| Result<std::unique_ptr<MetadataTable>> MetadataTable::Make(std::shared_ptr<Table> table, | ||
| Kind kind) { | ||
| if (table == nullptr) [[unlikely]] { | ||
| return InvalidArgument("Table cannot be null"); | ||
| } | ||
|
|
||
| switch (kind) { | ||
| case Kind::kSnapshots: | ||
| return SnapshotsTable::Make(table); | ||
| case Kind::kHistory: | ||
| return HistoryTable::Make(table); | ||
| } | ||
|
|
||
| return NotSupported("Unsupported metadata table type"); | ||
| } | ||
|
|
||
| } // namespace iceberg |
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,62 @@ | ||
| /* | ||
| * 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 <memory> | ||
|
|
||
| #include "iceberg/iceberg_export.h" | ||
| #include "iceberg/result.h" | ||
| #include "iceberg/table_identifier.h" | ||
| #include "iceberg/type_fwd.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| /// \brief Base class for Iceberg metadata tables. | ||
| class ICEBERG_EXPORT MetadataTable { | ||
| public: | ||
| enum class Kind { | ||
| kSnapshots, | ||
| kHistory, | ||
| }; | ||
|
|
||
| static Result<std::unique_ptr<MetadataTable>> Make(std::shared_ptr<Table> table, | ||
| Kind kind); | ||
|
|
||
| virtual ~MetadataTable(); | ||
|
|
||
| virtual Kind kind() const noexcept = 0; | ||
|
|
||
| const TableIdentifier& name() const { return identifier_; } | ||
|
|
||
| const std::shared_ptr<Schema>& schema() const { return schema_; } | ||
|
|
||
| const std::shared_ptr<Table>& source_table() const { return source_table_; } | ||
|
|
||
| protected: | ||
| explicit MetadataTable(std::shared_ptr<Table> source_table, TableIdentifier identifier, | ||
| std::shared_ptr<Schema> schema); | ||
|
|
||
| private: | ||
| TableIdentifier identifier_; | ||
| std::shared_ptr<Schema> schema_; | ||
| std::shared_ptr<Table> source_table_; | ||
| }; | ||
|
|
||
| } // namespace iceberg |
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,68 @@ | ||
| /* | ||
| * 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 "iceberg/inspect/snapshots_table.h" | ||
|
|
||
| #include <memory> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include "iceberg/schema.h" | ||
| #include "iceberg/schema_field.h" | ||
| #include "iceberg/table.h" | ||
| #include "iceberg/table_identifier.h" | ||
| #include "iceberg/type.h" | ||
|
|
||
| namespace iceberg { | ||
| namespace { | ||
|
|
||
| std::shared_ptr<Schema> MakeSnapshotsTableSchema() { | ||
| return std::make_shared<Schema>(std::vector<SchemaField>{ | ||
| SchemaField::MakeRequired(1, "committed_at", timestamp_tz()), | ||
| SchemaField::MakeRequired(2, "snapshot_id", int64()), | ||
| SchemaField::MakeOptional(3, "parent_id", int64()), | ||
| SchemaField::MakeOptional(4, "operation", string()), | ||
| SchemaField::MakeOptional(5, "manifest_list", string()), | ||
| SchemaField::MakeOptional(6, "summary", | ||
| std::make_shared<iceberg::MapType>( | ||
| SchemaField::MakeRequired(7, "key", string()), | ||
| SchemaField::MakeRequired(8, "value", string())))}); | ||
| } | ||
|
|
||
| TableIdentifier MakeSnapshotsTableName(const TableIdentifier& source_name) { | ||
| return TableIdentifier{.ns = source_name.ns, .name = source_name.name + ".snapshots"}; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| SnapshotsTable::SnapshotsTable(std::shared_ptr<Table> table) | ||
| : MetadataTable(table, MakeSnapshotsTableName(table->name()), | ||
| MakeSnapshotsTableSchema()) {} | ||
|
|
||
| SnapshotsTable::~SnapshotsTable() = default; | ||
|
|
||
| Result<std::unique_ptr<SnapshotsTable>> SnapshotsTable::Make( | ||
| std::shared_ptr<Table> table) { | ||
| if (table == nullptr) [[unlikely]] { | ||
| return InvalidArgument("Table cannot be null"); | ||
| } | ||
| return std::unique_ptr<SnapshotsTable>(new SnapshotsTable(std::move(table))); | ||
| } | ||
|
|
||
| } // namespace iceberg |
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,44 @@ | ||
| /* | ||
| * 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 <memory> | ||
|
|
||
| #include "iceberg/iceberg_export.h" | ||
| #include "iceberg/inspect/metadata_table.h" | ||
| #include "iceberg/result.h" | ||
| #include "iceberg/type_fwd.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| /// \brief Snapshots metadata table. | ||
| class ICEBERG_EXPORT SnapshotsTable : public MetadataTable { | ||
| public: | ||
| static Result<std::unique_ptr<SnapshotsTable>> Make(std::shared_ptr<Table> table); | ||
|
|
||
| ~SnapshotsTable() override; | ||
|
|
||
| Kind kind() const noexcept override { return Kind::kSnapshots; } | ||
|
|
||
| private: | ||
| explicit SnapshotsTable(std::shared_ptr<Table> table); | ||
| }; | ||
|
|
||
| } // namespace iceberg |
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.