Skip to content

Commit e125f97

Browse files
authored
Merge branch 'apache:main' into fix-issue-360
2 parents e8cb1b3 + b1901e7 commit e125f97

31 files changed

+1263
-202
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
env:
5555
CC: gcc-14
5656
CXX: g++-14
57-
run: ci/scripts/build_iceberg.sh $(pwd)
57+
run: ci/scripts/build_iceberg.sh $(pwd) ON
5858
- name: Build Example
5959
shell: bash
6060
env:
@@ -110,6 +110,7 @@ jobs:
110110
runs-on: ubuntu-24.04
111111
CC: gcc-14
112112
CXX: g++-14
113+
meson-setup-args: -Drest_integration_test=enabled
113114
- title: AMD64 Windows 2025
114115
runs-on: windows-2025
115116
meson-setup-args: --vsenv

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ option(ICEBERG_BUILD_SHARED "Build shared library" OFF)
4242
option(ICEBERG_BUILD_TESTS "Build tests" ON)
4343
option(ICEBERG_BUILD_BUNDLE "Build the battery included library" ON)
4444
option(ICEBERG_BUILD_REST "Build rest catalog client" ON)
45+
option(ICEBERG_BUILD_REST_INTEGRATION_TESTS "Build rest catalog integration tests" OFF)
4546
option(ICEBERG_ENABLE_ASAN "Enable Address Sanitizer" OFF)
4647
option(ICEBERG_ENABLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF)
4748

@@ -60,6 +61,11 @@ else()
6061
set(MSVC_TOOLCHAIN FALSE)
6162
endif()
6263

64+
if(ICEBERG_BUILD_REST_INTEGRATION_TESTS AND WIN32)
65+
set(ICEBERG_BUILD_REST_INTEGRATION_TESTS OFF)
66+
message(WARNING "Cannot build rest integration test on Windows, turning it off.")
67+
endif()
68+
6369
include(CMakeParseArguments)
6470
include(IcebergBuildUtils)
6571
include(IcebergSanitizer)

ci/scripts/build_iceberg.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set -eux
2121

2222
source_dir=${1}
2323
build_dir=${1}/build
24+
build_rest_integration_test=${2:-OFF}
2425

2526
mkdir ${build_dir}
2627
pushd ${build_dir}
@@ -34,6 +35,7 @@ CMAKE_ARGS=(
3435
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-${ICEBERG_HOME}}"
3536
"-DICEBERG_BUILD_STATIC=ON"
3637
"-DICEBERG_BUILD_SHARED=ON"
38+
"-DICEBERG_BUILD_REST_INTEGRATION_TESTS=${build_rest_integration_test}"
3739
)
3840

3941
if is_windows; then

meson.options

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,12 @@ option(
3636
description: 'Build rest catalog client',
3737
value: 'enabled',
3838
)
39+
40+
option(
41+
'rest_integration_test',
42+
type: 'feature',
43+
description: 'Build integration test for rest catalog',
44+
value: 'disabled',
45+
)
46+
3947
option('tests', type: 'feature', description: 'Build tests', value: 'enabled')

src/iceberg/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ set(ICEBERG_SOURCES
4444
manifest/v2_metadata.cc
4545
manifest/v3_metadata.cc
4646
metadata_columns.cc
47+
metrics_config.cc
4748
name_mapping.cc
4849
partition_field.cc
4950
partition_spec.cc
@@ -70,6 +71,7 @@ set(ICEBERG_SOURCES
7071
transform.cc
7172
transform_function.cc
7273
type.cc
74+
update/update_properties.cc
7375
util/bucket_util.cc
7476
util/conversions.cc
7577
util/decimal.cc
@@ -135,6 +137,7 @@ add_subdirectory(catalog)
135137
add_subdirectory(expression)
136138
add_subdirectory(manifest)
137139
add_subdirectory(row)
140+
add_subdirectory(update)
138141
add_subdirectory(util)
139142

140143
if(ICEBERG_BUILD_BUNDLE)

src/iceberg/meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ iceberg_sources = files(
6666
'manifest/v2_metadata.cc',
6767
'manifest/v3_metadata.cc',
6868
'metadata_columns.cc',
69+
'metrics_config.cc',
6970
'name_mapping.cc',
7071
'partition_field.cc',
7172
'partition_spec.cc',
@@ -92,6 +93,7 @@ iceberg_sources = files(
9293
'transform.cc',
9394
'transform_function.cc',
9495
'type.cc',
96+
'update/update_properties.cc',
9597
'util/bucket_util.cc',
9698
'util/conversions.cc',
9799
'util/decimal.cc',
@@ -165,9 +167,11 @@ install_headers(
165167
'location_provider.h',
166168
'metadata_columns.h',
167169
'metrics.h',
170+
'metrics_config.h',
168171
'name_mapping.h',
169172
'partition_field.h',
170173
'partition_spec.h',
174+
'pending_update.h',
171175
'result.h',
172176
'schema_field.h',
173177
'schema.h',
@@ -188,6 +192,7 @@ install_headers(
188192
'transform.h',
189193
'type_fwd.h',
190194
'type.h',
195+
'update/update_properties.h',
191196
],
192197
subdir: 'iceberg',
193198
)

src/iceberg/metrics_config.cc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
#include "iceberg/metrics_config.h"
21+
22+
#include <string>
23+
#include <unordered_map>
24+
25+
#include "iceberg/result.h"
26+
#include "iceberg/schema.h"
27+
#include "iceberg/table_properties.h"
28+
29+
namespace iceberg {
30+
31+
Status MetricsConfig::VerifyReferencedColumns(
32+
const std::unordered_map<std::string, std::string>& updates, const Schema& schema) {
33+
for (const auto& [key, value] : updates) {
34+
if (!key.starts_with(TableProperties::kMetricModeColumnConfPrefix)) {
35+
continue;
36+
}
37+
auto field_name =
38+
std::string_view(key).substr(TableProperties::kMetricModeColumnConfPrefix.size());
39+
auto field = schema.FindFieldByName(field_name);
40+
if (!field.has_value() || !field.value().has_value()) {
41+
return ValidationFailed(
42+
"Invalid metrics config, could not find column {} from table prop {} in "
43+
"schema {}",
44+
field_name, key, schema.ToString());
45+
}
46+
}
47+
return {};
48+
}
49+
50+
} // namespace iceberg

src/iceberg/metrics_config.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
/// \file iceberg/metrics_config.h
23+
/// \brief Metrics configuration for Iceberg tables
24+
25+
#include <string>
26+
#include <unordered_map>
27+
28+
#include "iceberg/iceberg_export.h"
29+
#include "iceberg/result.h"
30+
#include "iceberg/type_fwd.h"
31+
32+
namespace iceberg {
33+
34+
/// \brief Configuration utilities for table metrics
35+
class ICEBERG_EXPORT MetricsConfig {
36+
public:
37+
/// \brief Verify that all referenced columns are valid
38+
/// \param updates The updates to verify
39+
/// \param schema The schema to verify against
40+
/// \return OK if all referenced columns are valid
41+
static Status VerifyReferencedColumns(
42+
const std::unordered_map<std::string, std::string>& updates, const Schema& schema);
43+
};
44+
45+
} // namespace iceberg

src/iceberg/pending_update.h

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ namespace iceberg {
3737
///
3838
/// This matches the Java Iceberg pattern where BaseTransaction stores a
3939
/// List<PendingUpdate> without type parameters.
40-
class ICEBERG_EXPORT PendingUpdate {
40+
class ICEBERG_EXPORT PendingUpdate : public ErrorCollector {
4141
public:
4242
virtual ~PendingUpdate() = default;
4343

44+
/// \brief Verify that the changes are valid and apply them.
45+
/// \return Status::OK if the changes are valid, or an error:
46+
/// - ValidationFailed: if pending changes cannot be applied
47+
/// - InvalidArgument: if pending changes are conflicting
48+
virtual Status Apply() = 0;
49+
4450
/// \brief Apply and commit the pending changes to the table
4551
///
4652
/// Changes are committed by calling the underlying table's commit operation.
@@ -63,33 +69,4 @@ class ICEBERG_EXPORT PendingUpdate {
6369
PendingUpdate() = default;
6470
};
6571

66-
/// \brief Template class for type-safe table metadata changes using builder pattern
67-
///
68-
/// PendingUpdateTyped extends PendingUpdate with a type-safe Apply() method that
69-
/// returns the specific result type for each operation. Subclasses implement
70-
/// specific types of table updates such as schema changes, property updates, or
71-
/// snapshot-producing operations like appends and deletes.
72-
///
73-
/// Apply() can be used to validate and inspect the uncommitted changes before
74-
/// committing. Commit() applies the changes and commits them to the table.
75-
///
76-
/// \tparam T The type of result returned by Apply()
77-
template <typename T>
78-
class ICEBERG_EXPORT PendingUpdateTyped : public PendingUpdate, public ErrorCollector {
79-
public:
80-
~PendingUpdateTyped() override = default;
81-
82-
/// \brief Apply the pending changes and return the uncommitted result
83-
///
84-
/// This does not result in a permanent update.
85-
///
86-
/// \return the uncommitted changes that would be committed, or an error:
87-
/// - ValidationFailed: if pending changes cannot be applied
88-
/// - InvalidArgument: if pending changes are conflicting
89-
virtual Result<T> Apply() = 0;
90-
91-
protected:
92-
PendingUpdateTyped() = default;
93-
};
94-
9572
} // namespace iceberg

src/iceberg/table.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919

2020
#include "iceberg/table.h"
2121

22-
#include <algorithm>
23-
2422
#include "iceberg/catalog.h"
2523
#include "iceberg/partition_spec.h"
2624
#include "iceberg/schema.h"
2725
#include "iceberg/sort_order.h"
2826
#include "iceberg/table_metadata.h"
2927
#include "iceberg/table_properties.h"
3028
#include "iceberg/table_scan.h"
29+
#include "iceberg/update/update_properties.h"
3130
#include "iceberg/util/macros.h"
3231

3332
namespace iceberg {
@@ -110,6 +109,10 @@ const std::vector<SnapshotLogEntry>& Table::history() const {
110109
return metadata_->snapshot_log;
111110
}
112111

112+
std::unique_ptr<UpdateProperties> Table::UpdateProperties() const {
113+
return std::make_unique<iceberg::UpdateProperties>(identifier_, catalog_, metadata_);
114+
}
115+
113116
std::unique_ptr<Transaction> Table::NewTransaction() const {
114117
throw NotImplemented("Table::NewTransaction is not implemented");
115118
}

0 commit comments

Comments
 (0)