Skip to content

Commit c4e460d

Browse files
committed
Initial Iceberg support
1 parent c78aadf commit c4e460d

File tree

87 files changed

+10298
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+10298
-220
lines changed

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ cmake .. \
8181
-DENABLE_DEBUG_FUNCS=ON \
8282
-DENABLE_URL_FUNCS=ON \
8383
-DENABLE_AVRO=ON \
84+
-DENABLE_AWS_S3=ON \
8485
-DENABLE_AWS_MSK_IAM=ON \
8586
-DENABLE_CURL=${is_not_darwin} \
8687
-DENABLE_PULSAR=${is_not_darwin}

contrib/aws-cmake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ set(ENABLE_AWS_S3_DEFAULT OFF)
22
set(ENABLE_AWS_MSK_IAM_DEFAULT OFF) # proton: added
33

44
if(ENABLE_LIBRARIES AND (OS_LINUX OR OS_DARWIN) AND TARGET OpenSSL::Crypto)
5-
set(ENABLE_AWS_S3_DEFAULT OFF) # proton: added https://github.com/timeplus-io/proton/issues/918
5+
set(ENABLE_AWS_S3_DEFAULT ON)
66
set(ENABLE_AWS_MSK_IAM_DEFAULT ON) # proton: added
77
endif()
88

docker/packager/packager

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def parse_env_variables(build_type, compiler, sanitizer, package_type, image_typ
218218
cmake_flags.append('-DENABLE_CYRUS_SASL=ON')
219219
cmake_flags.append('-DENABLE_KRB5=ON')
220220
cmake_flags.append('-DENABLE_BROTLI=ON')
221-
cmake_flags.append('-DENABLE_S3=ON')
221+
cmake_flags.append('-DENABLE_AWS_S3=ON')
222222
cmake_flags.append('-DENABLE_AVRO=ON')
223223
cmake_flags.append('-DENABLE_AWS_MSK_IAM=ON')
224224

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ list (REMOVE_ITEM clickhouse_common_io_sources Common/malloc.cpp Common/new_dele
7878

7979
add_headers_and_sources(dbms Disks/IO)
8080
add_headers_and_sources(dbms Disks/ObjectStorages)
81+
82+
add_headers_and_sources(dbms Storages/NamedCollections)
83+
8184
if (USE_LIBPQXX)
8285
add_headers_and_sources(dbms Core/PostgreSQL)
8386
endif()
@@ -97,6 +100,8 @@ if (TARGET ch_contrib::azure_sdk)
97100
add_headers_and_sources(dbms Disks/ObjectStorages/AzureBlobStorage)
98101
endif()
99102

103+
add_headers_and_sources(dbms Databases/ApacheIceberg)
104+
100105
add_headers_and_sources(dbms Disks/ObjectStorages/Cached)
101106
add_headers_and_sources(dbms Disks/ObjectStorages/Web)
102107

@@ -208,6 +213,7 @@ add_object_library(clickhouse_server_http Server/HTTP)
208213
add_object_library(clickhouse_formats Formats)
209214
add_object_library(clickhouse_processors Processors)
210215
# proton : starts
216+
add_object_library(clickhouse_storages_iceberg Storages/Iceberg)
211217
add_object_library(clickhouse_processors_streaming Processors/Streaming)
212218

213219
add_object_library(clickhouse_formats_avro Formats/Avro)

src/Common/ErrorCodes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@
626626
M(676, CANNOT_PARSE_IPV6) \
627627
M(677, THREAD_WAS_CANCELED) \
628628
M(678, IO_URING_INIT_FAILED) \
629+
M(736, ICEBERG_CATALOG_ERROR) \
629630
M(679, IO_URING_SUBMIT_ERROR) \
630631
M(997, UNSUPPORTED) \
631632
M(998, INVALID_INTEGER_STRING) \

src/Common/Priority.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include <base/types.h>
4+
5+
/// Common type for priority values.
6+
/// Separate type (rather than `Int64` is used just to avoid implicit conversion errors and to default-initialize
7+
struct Priority
8+
{
9+
Int64 value = 0; /// Note that lower value means higher priority.
10+
constexpr operator Int64() const { return value; } /// NOLINT
11+
};

src/Common/SettingsChanges.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,30 @@ Field * SettingsChanges::tryGet(std::string_view name)
4646
return &change->value;
4747
}
4848

49+
bool SettingsChanges::insertSetting(std::string_view name, const Field & value)
50+
{
51+
auto it = std::find_if(begin(), end(), [&name](const SettingChange & change) { return change.name == name; });
52+
if (it != end())
53+
return false;
54+
emplace_back(name, value);
55+
return true;
56+
}
57+
58+
void SettingsChanges::setSetting(std::string_view name, const Field & value)
59+
{
60+
if (auto * setting_value = tryGet(name))
61+
*setting_value = value;
62+
else
63+
insertSetting(name, value);
64+
}
65+
66+
bool SettingsChanges::removeSetting(std::string_view name)
67+
{
68+
auto it = std::find_if(begin(), end(), [&name](const SettingChange & change) { return change.name == name; });
69+
if (it == end())
70+
return false;
71+
erase(it);
72+
return true;
73+
}
74+
4975
}

src/Common/SettingsChanges.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class SettingsChanges : public std::vector<SettingChange>
3030
bool tryGet(std::string_view name, Field & out_value) const;
3131
const Field * tryGet(std::string_view name) const;
3232
Field * tryGet(std::string_view name);
33+
34+
/// Inserts element if doesn't exists and returns true, otherwise just returns false
35+
bool insertSetting(std::string_view name, const Field & value);
36+
/// Sets element to value, inserts if doesn't exist
37+
void setSetting(std::string_view name, const Field & value);
38+
/// If element exists - removes it and returns true, otherwise returns false
39+
bool removeSetting(std::string_view name);
3340
};
3441

3542
}

src/Core/BaseSettingsFwdMacros.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#define DECLARE_SETTING_TRAIT(CLASS_NAME, TYPE) using CLASS_NAME##TYPE = SettingField##TYPE CLASS_NAME##Impl::*;
4+
5+
#define DECLARE_SETTING_SUBSCRIPT_OPERATOR(CLASS_NAME, TYPE) \
6+
const SettingField##TYPE & operator[](CLASS_NAME##TYPE t) const; \
7+
SettingField##TYPE & operator[](CLASS_NAME##TYPE t);

src/Core/BaseSettingsFwdMacrosImpl.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#define IMPLEMENT_SETTING_SUBSCRIPT_OPERATOR(CLASS_NAME, TYPE) \
4+
const SettingField##TYPE & CLASS_NAME::operator[](CLASS_NAME##TYPE t) const \
5+
{ \
6+
return impl.get()->*t; \
7+
} \
8+
SettingField##TYPE & CLASS_NAME::operator[](CLASS_NAME##TYPE t) \
9+
{ \
10+
return impl.get()->*t; \
11+
}

0 commit comments

Comments
 (0)