-
Notifications
You must be signed in to change notification settings - Fork 70
feat: Refresh method support for table #152
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
Changes from 12 commits
5c43a29
9485aea
aa2c11e
ec44f50
3141842
d7d4f55
5c5058d
50ab76e
c17bd3e
d8ee5ec
af38f2b
ff13911
018d8bb
dd7c679
0e99d68
95b0044
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,16 +21,36 @@ | |
|
|
||
| #include <algorithm> | ||
|
|
||
| #include "iceberg/catalog.h" | ||
| #include "iceberg/partition_spec.h" | ||
| #include "iceberg/schema.h" | ||
| #include "iceberg/sort_order.h" | ||
| #include "iceberg/table_metadata.h" | ||
| #include "iceberg/table_scan.h" | ||
| #include "iceberg/util/macros.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| const std::string& Table::uuid() const { return metadata_->table_uuid; } | ||
|
|
||
| Status Table::Refresh() { | ||
| if (!catalog_) { | ||
| return NotSupported("Refresh is not supported for table without a catalog"); | ||
| } | ||
|
|
||
| ICEBERG_ASSIGN_OR_RAISE(auto refreshed_table, catalog_->LoadTable(identifier_)); | ||
| if (metadata_location_ != refreshed_table->metadata_location_) { | ||
| metadata_ = std::move(refreshed_table->metadata_); | ||
| metadata_location_ = std::move(refreshed_table->metadata_location_); | ||
| io_ = std::move(refreshed_table->io_); | ||
|
|
||
| schemas_map_.reset(); | ||
| partition_spec_map_.reset(); | ||
| sort_orders_map_.reset(); | ||
|
Comment on lines
+47
to
+49
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't these get updated from the refreshed table?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this information is lazily initialized in the table, and the refreshed table hasn’t initialized these objects either, so a reset is sufficient. |
||
| } | ||
| return {}; | ||
| } | ||
|
|
||
| Result<std::shared_ptr<Schema>> Table::schema() const { return metadata_->Schema(); } | ||
|
|
||
| const std::shared_ptr<std::unordered_map<int32_t, std::shared_ptr<Schema>>>& | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * 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 "iceberg/catalog.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| class MockCatalog : public Catalog { | ||
| public: | ||
| MockCatalog() = default; | ||
| ~MockCatalog() override = default; | ||
|
|
||
| MOCK_METHOD(std::string_view, name, (), (const, override)); | ||
|
Check failure on line 31 in test/mock_catalog.h
|
||
lishuxu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| MOCK_METHOD(Status, CreateNamespace, | ||
|
Check failure on line 33 in test/mock_catalog.h
|
||
| (const Namespace&, (const std::unordered_map<std::string, std::string>&)), | ||
|
Check failure on line 34 in test/mock_catalog.h
|
||
| (override)); | ||
|
|
||
| MOCK_METHOD((Result<std::vector<Namespace>>), ListNamespaces, (const Namespace&), | ||
| (const, override)); | ||
|
|
||
| MOCK_METHOD((Result<std::unordered_map<std::string, std::string>>), | ||
| GetNamespaceProperties, (const Namespace&), (const, override)); | ||
|
|
||
| MOCK_METHOD(Status, UpdateNamespaceProperties, | ||
| (const Namespace&, (const std::unordered_map<std::string, std::string>&), | ||
| (const std::unordered_set<std::string>&)), | ||
| (override)); | ||
|
|
||
| MOCK_METHOD(Status, DropNamespace, (const Namespace&), (override)); | ||
|
|
||
| MOCK_METHOD(Result<bool>, NamespaceExists, (const Namespace&), (const, override)); | ||
|
|
||
| MOCK_METHOD((Result<std::vector<TableIdentifier>>), ListTables, (const Namespace&), | ||
| (const, override)); | ||
|
|
||
| MOCK_METHOD((Result<std::unique_ptr<Table>>), CreateTable, | ||
| (const TableIdentifier&, const Schema&, const PartitionSpec&, | ||
| const std::string&, (const std::unordered_map<std::string, std::string>&)), | ||
| (override)); | ||
|
|
||
| MOCK_METHOD((Result<std::unique_ptr<Table>>), UpdateTable, | ||
| (const TableIdentifier&, | ||
| (const std::vector<std::unique_ptr<UpdateRequirement>>&), | ||
| (const std::vector<std::unique_ptr<MetadataUpdate>>&)), | ||
| (override)); | ||
|
|
||
| MOCK_METHOD((Result<std::shared_ptr<Transaction>>), StageCreateTable, | ||
| (const TableIdentifier&, const Schema&, const PartitionSpec&, | ||
| const std::string&, (const std::unordered_map<std::string, std::string>&)), | ||
| (override)); | ||
|
|
||
| MOCK_METHOD(Result<bool>, TableExists, (const TableIdentifier&), (const, override)); | ||
|
|
||
| MOCK_METHOD(Status, DropTable, (const TableIdentifier&, bool), (override)); | ||
|
|
||
| MOCK_METHOD((Result<std::unique_ptr<Table>>), LoadTable, (const TableIdentifier&), | ||
| (override)); | ||
|
|
||
| MOCK_METHOD((Result<std::shared_ptr<Table>>), RegisterTable, | ||
| (const TableIdentifier&, const std::string&), (override)); | ||
|
|
||
| MOCK_METHOD((std::unique_ptr<TableBuilder>), BuildTable, | ||
| (const TableIdentifier&, const Schema&), (const, override)); | ||
| }; | ||
|
|
||
| } // namespace iceberg | ||
Uh oh!
There was an error while loading. Please reload this page.