iceberg-cpp
Loading...
Searching...
No Matches
mock_catalog.h
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 <gmock/gmock.h>
23#include <gtest/gtest.h>
24
25#include "iceberg/catalog.h"
26
27namespace iceberg {
28
29class MockCatalog : public Catalog {
30 public:
31 MockCatalog() = default;
32 ~MockCatalog() override = default;
33
34 MOCK_METHOD(std::string_view, name, (), (const, override));
35
36 MOCK_METHOD(Status, CreateNamespace,
37 (const Namespace&, (const std::unordered_map<std::string, std::string>&)),
38 (override));
39
40 MOCK_METHOD((Result<std::vector<Namespace>>), ListNamespaces, (const Namespace&),
41 (const, override));
42
43 MOCK_METHOD((Result<std::unordered_map<std::string, std::string>>),
44 GetNamespaceProperties, (const Namespace&), (const, override));
45
46 MOCK_METHOD(Status, UpdateNamespaceProperties,
47 (const Namespace&, (const std::unordered_map<std::string, std::string>&),
48 (const std::unordered_set<std::string>&)),
49 (override));
50
51 MOCK_METHOD(Status, DropNamespace, (const Namespace&), (override));
52
53 MOCK_METHOD(Result<bool>, NamespaceExists, (const Namespace&), (const, override));
54
55 MOCK_METHOD((Result<std::vector<TableIdentifier>>), ListTables, (const Namespace&),
56 (const, override));
57
58 MOCK_METHOD((Result<std::shared_ptr<Table>>), CreateTable,
59 (const TableIdentifier&, const std::shared_ptr<Schema>&,
60 const std::shared_ptr<PartitionSpec>&, const std::shared_ptr<SortOrder>&,
61 const std::string&, (const std::unordered_map<std::string, std::string>&)),
62 (override));
63
64 MOCK_METHOD((Result<std::shared_ptr<Table>>), UpdateTable,
65 (const TableIdentifier&,
66 (const std::vector<std::unique_ptr<TableRequirement>>&),
67 (const std::vector<std::unique_ptr<TableUpdate>>&)),
68 (override));
69
70 MOCK_METHOD((Result<std::shared_ptr<Transaction>>), StageCreateTable,
71 (const TableIdentifier&, const std::shared_ptr<Schema>&,
72 const std::shared_ptr<PartitionSpec>&, const std::shared_ptr<SortOrder>&,
73 const std::string&, (const std::unordered_map<std::string, std::string>&)),
74 (override));
75
76 MOCK_METHOD(Result<bool>, TableExists, (const TableIdentifier&), (const, override));
77
78 MOCK_METHOD(Status, DropTable, (const TableIdentifier&, bool), (override));
79
80 MOCK_METHOD(Status, RenameTable, (const TableIdentifier&, const TableIdentifier&),
81 (override));
82
83 MOCK_METHOD((Result<std::shared_ptr<Table>>), LoadTable, (const TableIdentifier&),
84 (override));
85
86 MOCK_METHOD((Result<std::shared_ptr<Table>>), RegisterTable,
87 (const TableIdentifier&, const std::string&), (override));
88};
89
90} // namespace iceberg
A Catalog API for table create, drop, and load operations.
Definition catalog.h:39
virtual Result< bool > NamespaceExists(const Namespace &ns) const =0
Check whether the namespace exists.
virtual Status DropTable(const TableIdentifier &identifier, bool purge)=0
Drop a table; optionally delete data and metadata files.
virtual Result< std::shared_ptr< Table > > CreateTable(const TableIdentifier &identifier, const std::shared_ptr< Schema > &schema, const std::shared_ptr< PartitionSpec > &spec, const std::shared_ptr< SortOrder > &order, const std::string &location, const std::unordered_map< std::string, std::string > &properties)=0
Create a table.
virtual Result< std::shared_ptr< Transaction > > StageCreateTable(const TableIdentifier &identifier, const std::shared_ptr< Schema > &schema, const std::shared_ptr< PartitionSpec > &spec, const std::shared_ptr< SortOrder > &order, const std::string &location, const std::unordered_map< std::string, std::string > &properties)=0
Start a transaction to create a table.
virtual Status UpdateNamespaceProperties(const Namespace &ns, const std::unordered_map< std::string, std::string > &updates, const std::unordered_set< std::string > &removals)=0
Update a namespace's properties by applying additions and removals.
virtual Result< std::shared_ptr< Table > > UpdateTable(const TableIdentifier &identifier, const std::vector< std::unique_ptr< TableRequirement > > &requirements, const std::vector< std::unique_ptr< TableUpdate > > &updates)=0
Update a table.
virtual std::string_view name() const =0
Return the name for this catalog.
virtual Status DropNamespace(const Namespace &ns)=0
Drop a namespace.
virtual Result< bool > TableExists(const TableIdentifier &identifier) const =0
Check whether table exists.
virtual Result< std::shared_ptr< Table > > LoadTable(const TableIdentifier &identifier)=0
Load a table.
virtual Result< std::vector< TableIdentifier > > ListTables(const Namespace &ns) const =0
Return all the identifiers under this namespace.
virtual Result< std::vector< Namespace > > ListNamespaces(const Namespace &ns) const =0
List child namespaces from the given namespace.
virtual Result< std::shared_ptr< Table > > RegisterTable(const TableIdentifier &identifier, const std::string &metadata_file_location)=0
Register a table with the catalog if it does not exist.
virtual Status RenameTable(const TableIdentifier &from, const TableIdentifier &to)=0
Rename a table.
virtual Result< std::unordered_map< std::string, std::string > > GetNamespaceProperties(const Namespace &ns) const =0
Get metadata properties for a namespace.
virtual Status CreateNamespace(const Namespace &ns, const std::unordered_map< std::string, std::string > &properties)=0
Create a namespace with associated properties.
Definition mock_catalog.h:29
A namespace in a catalog.
Definition table_identifier.h:35
Identifies a table in iceberg catalog.
Definition table_identifier.h:46