iceberg-cpp
Loading...
Searching...
No Matches
hive_catalog.h
Go to the documentation of this file.
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 <memory>
23#include <string>
24#include <unordered_set>
25
26#include "iceberg/catalog.h"
29#include "iceberg/result.h"
30
33
34namespace iceberg::hive {
35
41class ICEBERG_HIVE_EXPORT HiveCatalog : public Catalog,
42 public std::enable_shared_from_this<HiveCatalog> {
43 public:
44 ~HiveCatalog() override;
45
46 HiveCatalog(const HiveCatalog&) = delete;
47 HiveCatalog& operator=(const HiveCatalog&) = delete;
48 HiveCatalog(HiveCatalog&&) = delete;
49 HiveCatalog& operator=(HiveCatalog&&) = delete;
50
57
58 std::string_view name() const override;
59
61 const Namespace& ns,
62 const std::unordered_map<std::string, std::string>& properties) override;
63
65
67 const Namespace& ns) const override;
68
69 Status DropNamespace(const Namespace& ns) override;
70
71 Result<bool> NamespaceExists(const Namespace& ns) const override;
72
74 const Namespace& ns, const std::unordered_map<std::string, std::string>& updates,
75 const std::unordered_set<std::string>& removals) override;
76
78
80 const TableIdentifier& identifier, const std::shared_ptr<Schema>& schema,
81 const std::shared_ptr<PartitionSpec>& spec, const std::shared_ptr<SortOrder>& order,
82 const std::string& location,
83 const std::unordered_map<std::string, std::string>& properties) override;
84
86 const TableIdentifier& identifier,
87 const std::vector<std::unique_ptr<TableRequirement>>& requirements,
88 const std::vector<std::unique_ptr<TableUpdate>>& updates) override;
89
91 const TableIdentifier& identifier, const std::shared_ptr<Schema>& schema,
92 const std::shared_ptr<PartitionSpec>& spec, const std::shared_ptr<SortOrder>& order,
93 const std::string& location,
94 const std::unordered_map<std::string, std::string>& properties) override;
95
96 Result<bool> TableExists(const TableIdentifier& identifier) const override;
97
98 Status DropTable(const TableIdentifier& identifier, bool purge) override;
99
100 Status RenameTable(const TableIdentifier& from, const TableIdentifier& to) override;
101
103
105 const TableIdentifier& identifier,
106 const std::string& metadata_file_location) override;
107
108 private:
109 explicit HiveCatalog(HiveCatalogProperties config);
110
111 HiveCatalogProperties config_;
112 std::string name_;
113};
114
115} // namespace iceberg::hive
Define the catalog API for table and namespace operations.
A Catalog API for table create, drop, and load operations.
Definition catalog.h:42
Configuration for the iceberg_hive HiveCatalog.
Definition hive_catalog_properties.h:47
Catalog implementation backed by a Hive Metastore.
Definition hive_catalog.h:42
Result< bool > TableExists(const TableIdentifier &identifier) const override
Check whether table exists.
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) override
Create a table.
Status DropTable(const TableIdentifier &identifier, bool purge) override
Drop a table; optionally delete data and metadata files.
Result< std::shared_ptr< Table > > LoadTable(const TableIdentifier &identifier) override
Load a table.
Result< std::vector< TableIdentifier > > ListTables(const Namespace &ns) const override
Return all the identifiers under this namespace.
Status RenameTable(const TableIdentifier &from, const TableIdentifier &to) override
Rename a table.
Result< bool > NamespaceExists(const Namespace &ns) const override
Check whether the namespace exists.
Status DropNamespace(const Namespace &ns) override
Drop a namespace.
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) override
Start a transaction to create a table.
Result< std::shared_ptr< Table > > RegisterTable(const TableIdentifier &identifier, const std::string &metadata_file_location) override
Register a table with the catalog if it does not exist.
Result< std::unordered_map< std::string, std::string > > GetNamespaceProperties(const Namespace &ns) const override
Get metadata properties for a namespace.
Status UpdateNamespaceProperties(const Namespace &ns, const std::unordered_map< std::string, std::string > &updates, const std::unordered_set< std::string > &removals) override
Update a namespace's properties by applying additions and removals.
Status CreateNamespace(const Namespace &ns, const std::unordered_map< std::string, std::string > &properties) override
Create a namespace with associated properties.
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) override
Update a table.
std::string_view name() const override
Return the name for this catalog.
Result< std::vector< Namespace > > ListNamespaces(const Namespace &ns) const override
List child namespaces from the given namespace.
static Result< std::shared_ptr< HiveCatalog > > Make(const HiveCatalogProperties &config)
Construct a HiveCatalog from config.
Configuration for connecting to a Hive Metastore (HMS) over Thrift.
Define symbol visibility macros for the Hive catalog library.
Hive catalog APIs.
Definition hive_catalog.h:34
std::expected< T, E > Result
Result alias.
Definition result.h:88
Define Result, Status, and error helpers.
A namespace in a catalog.
Definition table_identifier.h:35
Identifies a table in iceberg catalog.
Definition table_identifier.h:46