Skip to content

Commit 2d7ceaa

Browse files
committed
remove TableOperations
1 parent 1aaa348 commit 2d7ceaa

File tree

6 files changed

+75
-119
lines changed

6 files changed

+75
-119
lines changed

src/iceberg/catalog.h

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@
2525
#include <string_view>
2626
#include <vector>
2727

28+
#include "iceberg/error.h"
2829
#include "iceberg/expected.h"
2930
#include "iceberg/table_identifier.h"
3031
#include "iceberg/type_fwd.h"
3132

3233
namespace iceberg {
3334

3435
/// \brief A Catalog API for table create, drop, and load operations.
36+
///
37+
/// Note that these functions are named after the corresponding operationId
38+
/// specified by the Iceberg Rest Catalog API.
3539
class ICEBERG_EXPORT Catalog {
3640
public:
3741
virtual ~Catalog() = default;
@@ -42,9 +46,9 @@ class ICEBERG_EXPORT Catalog {
4246
/// \brief Return all the identifiers under this namespace
4347
///
4448
/// \param ns a namespace
45-
/// \return a list of identifiers for tables or Error::kNoSuchNamespace
49+
/// \return a list of identifiers for tables or ErrorKind::kNoSuchNamespace
4650
/// if the namespace does not exist
47-
virtual expected<std::vector<TableIdentifier>, ErrorKind> ListTables(
51+
virtual expected<std::vector<TableIdentifier>, Error> ListTables(
4852
const Namespace& ns) const = 0;
4953

5054
/// \brief Create a table
@@ -54,22 +58,33 @@ class ICEBERG_EXPORT Catalog {
5458
/// \param spec a partition spec
5559
/// \param location a location for the table; leave empty if unspecified
5660
/// \param properties a string map of table properties
57-
/// \return a Table instance or Error::kAlreadyExists if the table already exists
58-
virtual expected<std::unique_ptr<Table>, ErrorKind> CreateTable(
61+
/// \return a Table instance or ErrorKind::kAlreadyExists if the table already exists
62+
virtual expected<std::unique_ptr<Table>, Error> CreateTable(
5963
const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
6064
const std::string& location,
6165
const std::map<std::string, std::string>& properties) = 0;
6266

67+
/// \brief Update a table
68+
///
69+
/// \param identifier a table identifier
70+
/// \param requirements a list of table requirements
71+
/// \param updates a list of table updates
72+
/// \return a Table instance or ErrorKind::kAlreadyExists if the table already exists
73+
virtual expected<std::unique_ptr<Table>, Error> UpdateTable(
74+
const TableIdentifier& identifier,
75+
const std::vector<std::unique_ptr<UpdateRequirement>>& requirements,
76+
const std::vector<std::unique_ptr<MetadataUpdate>>& updates) = 0;
77+
6378
/// \brief Start a transaction to create a table
6479
///
6580
/// \param identifier a table identifier
6681
/// \param schema a schema
6782
/// \param spec a partition spec
6883
/// \param location a location for the table; leave empty if unspecified
6984
/// \param properties a string map of table properties
70-
/// \return a Transaction to create the table or Error::kAlreadyExists if the table
85+
/// \return a Transaction to create the table or ErrorKind::kAlreadyExists if the table
7186
/// already exists
72-
virtual expected<std::shared_ptr<Transaction>, ErrorKind> NewCreateTableTransaction(
87+
virtual expected<std::shared_ptr<Transaction>, Error> StageCreateTable(
7388
const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
7489
const std::string& location,
7590
const std::map<std::string, std::string>& properties) = 0;
@@ -94,16 +109,16 @@ class ICEBERG_EXPORT Catalog {
94109
///
95110
/// \param identifier a table identifier
96111
/// \return instance of Table implementation referred to by identifier or
97-
/// Error::kNoSuchTable if the table does not exist
98-
virtual expected<std::shared_ptr<Table>, ErrorKind> LoadTable(
112+
/// ErrorKind::kNoSuchTable if the table does not exist
113+
virtual expected<std::shared_ptr<Table>, Error> LoadTable(
99114
const TableIdentifier& identifier) const = 0;
100115

101116
/// \brief Register a table with the catalog if it does not exist
102117
///
103118
/// \param identifier a table identifier
104119
/// \param metadata_file_location the location of a metadata file
105-
/// \return a Table instance or Error::kAlreadyExists if the table already exists
106-
virtual expected<std::shared_ptr<Table>, ErrorKind> RegisterTable(
120+
/// \return a Table instance or ErrorKind::kAlreadyExists if the table already exists
121+
virtual expected<std::shared_ptr<Table>, Error> RegisterTable(
107122
const TableIdentifier& identifier, const std::string& metadata_file_location) = 0;
108123

109124
/// \brief Initialize a catalog given a custom name and a map of catalog properties
@@ -172,7 +187,7 @@ class ICEBERG_EXPORT Catalog {
172187
/// \brief Starts a transaction to create the table
173188
///
174189
/// \return the Transaction to create the table
175-
virtual std::unique_ptr<Transaction> CreateTransaction() = 0;
190+
virtual std::unique_ptr<Transaction> StageCreate() = 0;
176191
};
177192
};
178193

src/iceberg/demo.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "iceberg/location_provider.h"
2525
#include "iceberg/puffin.h"
2626
#include "iceberg/table.h"
27-
#include "iceberg/table_operations.h"
2827
#include "iceberg/transaction.h"
2928

3029
namespace iceberg {

src/iceberg/error.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#pragma once
21+
22+
#include <string>
23+
24+
#include "iceberg/iceberg_export.h"
25+
26+
namespace iceberg {
27+
28+
/// \brief Error types for iceberg.
29+
/// TODO: add more and sort them based on some rules.
30+
enum class ErrorKind {
31+
kNoSuchNamespace,
32+
kAlreadyExists,
33+
kNoSuchTable,
34+
kCommitStateUnknown,
35+
};
36+
37+
/// \brief Error with a kind and a message.
38+
struct ICEBERG_EXPORT [[nodiscard]] Error {
39+
ErrorKind kind;
40+
std::string message;
41+
};
42+
43+
} // namespace iceberg

src/iceberg/table.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <string>
2525
#include <vector>
2626

27+
#include "iceberg/error.h"
2728
#include "iceberg/expected.h"
2829
#include "iceberg/iceberg_export.h"
2930
#include "iceberg/type_fwd.h"
@@ -42,7 +43,7 @@ class ICEBERG_EXPORT Table {
4243
virtual const std::string& uuid() const = 0;
4344

4445
/// \brief Refresh the current table metadata
45-
virtual void Refresh() = 0;
46+
virtual expected<void, Error> Refresh() = 0;
4647

4748
/// \brief Return the schema for this table
4849
virtual const std::shared_ptr<Schema>& schema() const = 0;
@@ -76,7 +77,7 @@ class ICEBERG_EXPORT Table {
7677
///
7778
/// \param snapshot_id the ID of the snapshot to get
7879
/// \return the Snapshot with the given id
79-
virtual expected<std::shared_ptr<Snapshot>, ErrorKind> snapshot(
80+
virtual expected<std::shared_ptr<Snapshot>, Error> snapshot(
8081
int64_t snapshot_id) const = 0;
8182

8283
/// \brief Get the snapshots of this table

src/iceberg/table_operations.h

Lines changed: 0 additions & 95 deletions
This file was deleted.

src/iceberg/type_fwd.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,12 @@ class TimestampTzType;
8181
class Type;
8282
class UuidType;
8383

84-
/// \brief Error types for iceberg.
85-
/// TODO: add more and sort them based on some rules.
86-
enum class ErrorKind {
87-
kNoSuchNamespace,
88-
kAlreadyExists,
89-
kNoSuchTable,
90-
kCommitStateUnknown,
91-
};
92-
9384
struct Namespace;
9485
struct TableIdentifier;
9586

9687
class Catalog;
9788
class LocationProvider;
9889
class Table;
99-
class TableOperations;
10090
class Transaction;
10191

10292
/// ----------------------------------------------------------------------------
@@ -110,6 +100,9 @@ class SortOrder;
110100
class StructLike;
111101
class TableMetadata;
112102

103+
class MetadataUpdate;
104+
class UpdateRequirement;
105+
113106
class AppendFiles;
114107
class TableScan;
115108

0 commit comments

Comments
 (0)