Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cmake_modules/IcebergThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -742,3 +742,14 @@ endif()
if(ICEBERG_BUILD_SQL_CATALOG)
resolve_sql_catalog_dependencies()
endif()

# Arrow's bundled build creates the Thrift C++ runtime as a `thrift` target

@wgtmac wgtmac Jun 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend follow resolve_aws_sdk_dependency and ICEBERG_AWSSDK_BUNDLED to either bundle or use system thrift.

# scoped to its FetchContent directory, where iceberg_hive cannot see it.
# Promote it to a global `thrift::thrift` alias so iceberg_hive can link the
# generated Hive Metastore bindings against it.
if(ICEBERG_BUILD_HIVE
AND TARGET thrift
AND NOT TARGET thrift::thrift)
add_library(thrift::thrift INTERFACE IMPORTED GLOBAL)
target_link_libraries(thrift::thrift INTERFACE thrift)
endif()
76 changes: 71 additions & 5 deletions src/iceberg/catalog/hive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,77 @@
# specific language governing permissions and limitations
# under the License.

# Skeleton for the iceberg_hive library target.
# The iceberg_hive library: a Hive Metastore (HMS) catalog client built on
# generated Apache Thrift bindings. Layout mirrors iceberg_rest.

# ----------------------------------------------------------------------
# Hive Metastore Thrift bindings.
#
# Sources, dependency wiring and the actual `iceberg_hive` library target
# are introduced in follow-up commits. For now this file installs only the
# public export header so that the directory is wired into the build system
# end-to-end.
# These are checked into gen-cpp/ rather than generated at build time, so a
# normal build needs no Thrift IDL compiler — only the Thrift C++ runtime,
# which comes from Apache Arrow's bundled build. Regenerate them with
# dev/update_hive_thrift.sh whenever thirdparty/hive_metastore/*.thrift changes.

set(_thrift_gen_dir ${CMAKE_CURRENT_SOURCE_DIR}/gen-cpp)

set(ICEBERG_HIVE_THRIFT_GEN_SOURCES
${_thrift_gen_dir}/FacebookService.cpp
${_thrift_gen_dir}/fb303_types.cpp
${_thrift_gen_dir}/hive_metastore_constants.cpp
${_thrift_gen_dir}/hive_metastore_types.cpp
${_thrift_gen_dir}/ThriftHiveMetastore.cpp)

# Upstream-generated code: skip lint/format, and downgrade the deprecated
# std::iterator warning from Arrow's bundled Thrift 0.22 headers (removed
# upstream in Thrift 0.23, THRIFT-5698) so it does not trip -Werror.
set_source_files_properties(${ICEBERG_HIVE_THRIFT_GEN_SOURCES}
PROPERTIES SKIP_LINTING TRUE
COMPILE_OPTIONS
"$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wno-error=deprecated-declarations>"
)

# ----------------------------------------------------------------------
# iceberg_hive library

if(NOT TARGET thrift::thrift)
message(FATAL_ERROR "iceberg_hive requires a `thrift::thrift` target, normally "
"provided by Apache Arrow's bundled Thrift. Build with "
"-DICEBERG_BUILD_BUNDLE=ON (the default).")
endif()

set(ICEBERG_HIVE_SOURCES hive_catalog.cc hive_catalog_properties.cc
${ICEBERG_HIVE_THRIFT_GEN_SOURCES})

set(ICEBERG_HIVE_STATIC_BUILD_INTERFACE_LIBS)
set(ICEBERG_HIVE_SHARED_BUILD_INTERFACE_LIBS)
set(ICEBERG_HIVE_STATIC_INSTALL_INTERFACE_LIBS)
set(ICEBERG_HIVE_SHARED_INSTALL_INTERFACE_LIBS)

list(APPEND ICEBERG_HIVE_STATIC_BUILD_INTERFACE_LIBS
"$<IF:$<TARGET_EXISTS:iceberg_static>,iceberg_static,iceberg_shared>" thrift::thrift)
list(APPEND ICEBERG_HIVE_SHARED_BUILD_INTERFACE_LIBS
"$<IF:$<TARGET_EXISTS:iceberg_shared>,iceberg_shared,iceberg_static>" thrift::thrift)
list(APPEND
ICEBERG_HIVE_STATIC_INSTALL_INTERFACE_LIBS
"$<IF:$<TARGET_EXISTS:iceberg::iceberg_static>,iceberg::iceberg_static,iceberg::iceberg_shared>"
thrift::thrift)
list(APPEND
ICEBERG_HIVE_SHARED_INSTALL_INTERFACE_LIBS
"$<IF:$<TARGET_EXISTS:iceberg::iceberg_shared>,iceberg::iceberg_shared,iceberg::iceberg_static>"
thrift::thrift)

add_iceberg_lib(iceberg_hive
SOURCES
${ICEBERG_HIVE_SOURCES}
PRIVATE_INCLUDES
${_thrift_gen_dir}
SHARED_LINK_LIBS
${ICEBERG_HIVE_SHARED_BUILD_INTERFACE_LIBS}
STATIC_LINK_LIBS
${ICEBERG_HIVE_STATIC_BUILD_INTERFACE_LIBS}
STATIC_INSTALL_INTERFACE_LIBS
${ICEBERG_HIVE_STATIC_INSTALL_INTERFACE_LIBS}
SHARED_INSTALL_INTERFACE_LIBS
${ICEBERG_HIVE_SHARED_INSTALL_INTERFACE_LIBS})

iceberg_install_all_headers(iceberg/catalog/hive)
132 changes: 132 additions & 0 deletions src/iceberg/catalog/hive/hive_catalog.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* 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/catalog/hive/hive_catalog.h"

#include <memory>
#include <utility>

#include "iceberg/util/macros.h"

namespace iceberg::hive {

namespace {

constexpr std::string_view kNotImplementedMessage =
"HiveCatalog method is not yet implemented.";

} // namespace

HiveCatalog::HiveCatalog(HiveCatalogProperties config)
: config_(std::move(config)), name_(config_.Get(HiveCatalogProperties::kName)) {}

HiveCatalog::~HiveCatalog() = default;

Result<std::shared_ptr<HiveCatalog>> HiveCatalog::Make(
const HiveCatalogProperties& config) {
ICEBERG_RETURN_UNEXPECTED(config.Uri());
return std::shared_ptr<HiveCatalog>(new HiveCatalog(config));
}

std::string_view HiveCatalog::name() const { return name_; }

Status HiveCatalog::CreateNamespace(
const Namespace& /*ns*/,
const std::unordered_map<std::string, std::string>& /*properties*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<std::vector<Namespace>> HiveCatalog::ListNamespaces(
const Namespace& /*ns*/) const {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<std::unordered_map<std::string, std::string>> HiveCatalog::GetNamespaceProperties(
const Namespace& /*ns*/) const {
return NotImplemented("{}", kNotImplementedMessage);
}

Status HiveCatalog::DropNamespace(const Namespace& /*ns*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<bool> HiveCatalog::NamespaceExists(const Namespace& /*ns*/) const {
return NotImplemented("{}", kNotImplementedMessage);
}

Status HiveCatalog::UpdateNamespaceProperties(
const Namespace& /*ns*/,
const std::unordered_map<std::string, std::string>& /*updates*/,
const std::unordered_set<std::string>& /*removals*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<std::vector<TableIdentifier>> HiveCatalog::ListTables(
const Namespace& /*ns*/) const {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<std::shared_ptr<Table>> HiveCatalog::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*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<std::shared_ptr<Table>> HiveCatalog::UpdateTable(
const TableIdentifier& /*identifier*/,
const std::vector<std::unique_ptr<TableRequirement>>& /*requirements*/,
const std::vector<std::unique_ptr<TableUpdate>>& /*updates*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<std::shared_ptr<Transaction>> HiveCatalog::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*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<bool> HiveCatalog::TableExists(const TableIdentifier& /*identifier*/) const {
return NotImplemented("{}", kNotImplementedMessage);
}

Status HiveCatalog::DropTable(const TableIdentifier& /*identifier*/, bool /*purge*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

Status HiveCatalog::RenameTable(const TableIdentifier& /*from*/,
const TableIdentifier& /*to*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<std::shared_ptr<Table>> HiveCatalog::LoadTable(
const TableIdentifier& /*identifier*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

Result<std::shared_ptr<Table>> HiveCatalog::RegisterTable(
const TableIdentifier& /*identifier*/,
const std::string& /*metadata_file_location*/) {
return NotImplemented("{}", kNotImplementedMessage);
}

} // namespace iceberg::hive
115 changes: 115 additions & 0 deletions src/iceberg/catalog/hive/hive_catalog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* 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 <string>
#include <unordered_set>

#include "iceberg/catalog.h"
#include "iceberg/catalog/hive/hive_catalog_properties.h"
#include "iceberg/catalog/hive/iceberg_hive_export.h"
#include "iceberg/result.h"

/// \file iceberg/catalog/hive/hive_catalog.h
/// \brief HiveCatalog implementation for talking to a Hive Metastore (HMS).

namespace iceberg::hive {

/// \brief Catalog implementation backed by a Hive Metastore.
///
/// Currently a stub: every Catalog method returns
/// ErrorKind::kNotImplemented. Follow-up changes add the HMS Thrift client
/// and wire each method to the metastore.
class ICEBERG_HIVE_EXPORT HiveCatalog : public Catalog,
public std::enable_shared_from_this<HiveCatalog> {
public:
~HiveCatalog() override;

HiveCatalog(const HiveCatalog&) = delete;
HiveCatalog& operator=(const HiveCatalog&) = delete;
HiveCatalog(HiveCatalog&&) = delete;
HiveCatalog& operator=(HiveCatalog&&) = delete;

/// \brief Construct a HiveCatalog from `config`.
///
/// Only stores the configuration for now; HMS connection setup comes
/// with the Thrift client. Returns an error if the supplied
/// configuration is missing required fields (currently: the URI).
static Result<std::shared_ptr<HiveCatalog>> Make(const HiveCatalogProperties& config);

std::string_view name() const override;

Status CreateNamespace(
const Namespace& ns,
const std::unordered_map<std::string, std::string>& properties) override;

Result<std::vector<Namespace>> ListNamespaces(const Namespace& ns) const override;

Result<std::unordered_map<std::string, std::string>> GetNamespaceProperties(
const Namespace& ns) const override;

Status DropNamespace(const Namespace& ns) override;

Result<bool> NamespaceExists(const Namespace& ns) const override;

Status UpdateNamespaceProperties(
const Namespace& ns, const std::unordered_map<std::string, std::string>& updates,
const std::unordered_set<std::string>& removals) override;

Result<std::vector<TableIdentifier>> ListTables(const Namespace& ns) const override;

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;

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;

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;

Result<bool> TableExists(const TableIdentifier& identifier) const override;

Status DropTable(const TableIdentifier& identifier, bool purge) override;

Status RenameTable(const TableIdentifier& from, const TableIdentifier& to) override;

Result<std::shared_ptr<Table>> LoadTable(const TableIdentifier& identifier) override;

Result<std::shared_ptr<Table>> RegisterTable(
const TableIdentifier& identifier,
const std::string& metadata_file_location) override;

private:
explicit HiveCatalog(HiveCatalogProperties config);

HiveCatalogProperties config_;
std::string name_;
};

} // namespace iceberg::hive
Loading
Loading