Skip to content

Commit 917c318

Browse files
authored
Merge branch 'apache:main' into feat/literal2
2 parents 59e57fc + 78d06bf commit 917c318

Some content is hidden

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

44 files changed

+1478
-176
lines changed

.github/workflows/cpp-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Run build
3838
run: |
3939
mkdir build && cd build
40-
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
40+
cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
4141
cmake --build .
4242
- uses: cpp-linter/cpp-linter-action@f91c446a32ae3eb9f98fef8c9ed4c7cb613a4f8a
4343
id: linter

.github/workflows/sanitizer_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Configure and Build with ASAN & UBSAN
4646
run: |
4747
mkdir build && cd build
48-
cmake .. -DCMAKE_BUILD_TYPE=Debug -DICEBERG_ENABLE_ASAN=ON -DICEBERG_ENABLE_UBSAN=ON
48+
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -DICEBERG_ENABLE_ASAN=ON -DICEBERG_ENABLE_UBSAN=ON
4949
cmake --build . --verbose
5050
- name: Run Tests
5151
working-directory: build

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ cmake-build-release/
2323

2424
# intellij files
2525
.idea
26+
27+
# vscode files
28+
.vscode

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ C++ implementation of [Apache Iceberg™](https://iceberg.apache.org/).
3232

3333
```bash
3434
cd iceberg-cpp
35-
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install -DICEBERG_BUILD_STATIC=ON -DICEBERG_BUILD_SHARED=ON
35+
cmake -S . -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/path/to/install -DICEBERG_BUILD_STATIC=ON -DICEBERG_BUILD_SHARED=ON
3636
cmake --build build
3737
ctest --test-dir build --output-on-failure
3838
cmake --install build
@@ -43,7 +43,7 @@ cmake --install build
4343
#### Vendored Apache Arrow (default)
4444

4545
```bash
46-
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install -DICEBERG_BUILD_BUNDLE=ON
46+
cmake -S . -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/path/to/install -DICEBERG_BUILD_BUNDLE=ON
4747
cmake --build build
4848
ctest --test-dir build --output-on-failure
4949
cmake --install build
@@ -52,7 +52,7 @@ cmake --install build
5252
#### Provided Apache Arrow
5353

5454
```bash
55-
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install -DCMAKE_PREFIX_PATH=/path/to/arrow -DICEBERG_BUILD_BUNDLE=ON
55+
cmake -S . -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/path/to/install -DCMAKE_PREFIX_PATH=/path/to/arrow -DICEBERG_BUILD_BUNDLE=ON
5656
cmake --build build
5757
ctest --test-dir build --output-on-failure
5858
cmake --install build
@@ -64,14 +64,14 @@ After installing the core libraries, you can build the examples:
6464

6565
```bash
6666
cd iceberg-cpp/example
67-
cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/install
67+
cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH=/path/to/install
6868
cmake --build build
6969
```
7070

7171
If you are using provided Apache Arrow, you need to include `/path/to/arrow` in `CMAKE_PREFIX_PATH` as below.
7272

7373
```bash
74-
cmake -S . -B build -DCMAKE_PREFIX_PATH="/path/to/install;/path/to/arrow"
74+
cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH="/path/to/install;/path/to/arrow"
7575
```
7676

7777
## Contribute

ci/scripts/build_example.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ is_windows() {
3030
}
3131

3232
CMAKE_ARGS=(
33+
"-G Ninja"
3334
"-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX:-${ICEBERG_HOME}}"
3435
)
3536

ci/scripts/build_iceberg.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ is_windows() {
3030
}
3131

3232
CMAKE_ARGS=(
33+
"-G Ninja"
3334
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-${ICEBERG_HOME}}"
3435
"-DICEBERG_BUILD_STATIC=ON"
3536
"-DICEBERG_BUILD_SHARED=ON"

example/demo_example.cc

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,63 @@
1919

2020
#include <iostream>
2121

22+
#include "iceberg/arrow/arrow_file_io.h"
2223
#include "iceberg/avro/avro_register.h"
23-
#include "iceberg/file_reader.h"
24+
#include "iceberg/catalog/in_memory_catalog.h"
2425
#include "iceberg/parquet/parquet_register.h"
26+
#include "iceberg/table.h"
27+
#include "iceberg/table_scan.h"
28+
29+
int main(int argc, char** argv) {
30+
if (argc != 4) {
31+
std::cerr << "Usage: " << argv[0]
32+
<< " <warehouse_location> <table_name> <table_location>" << std::endl;
33+
return 0;
34+
}
35+
36+
const std::string warehouse_location = argv[1];
37+
const std::string table_name = argv[2];
38+
const std::string table_location = argv[3];
39+
const std::unordered_map<std::string, std::string> properties;
2540

26-
int main() {
2741
iceberg::avro::RegisterAll();
2842
iceberg::parquet::RegisterAll();
29-
auto open_result = iceberg::ReaderFactoryRegistry::Open(
30-
iceberg::FileFormatType::kAvro, {.path = "non-existing-file.avro"});
31-
if (!open_result.has_value()) {
32-
std::cerr << "Failed to open avro file" << std::endl;
43+
44+
auto catalog = iceberg::InMemoryCatalog::Make("test", iceberg::arrow::MakeLocalFileIO(),
45+
warehouse_location, properties);
46+
47+
auto register_result = catalog->RegisterTable({.name = table_name}, table_location);
48+
if (!register_result.has_value()) {
49+
std::cerr << "Failed to register table: " << register_result.error().message
50+
<< std::endl;
3351
return 1;
3452
}
53+
54+
auto load_result = catalog->LoadTable({.name = table_name});
55+
if (!load_result.has_value()) {
56+
std::cerr << "Failed to load table: " << load_result.error().message << std::endl;
57+
return 1;
58+
}
59+
60+
auto table = std::move(load_result.value());
61+
auto scan_result = table->NewScan()->Build();
62+
if (!scan_result.has_value()) {
63+
std::cerr << "Failed to build scan: " << scan_result.error().message << std::endl;
64+
return 1;
65+
}
66+
67+
auto scan = std::move(scan_result.value());
68+
auto plan_result = scan->PlanFiles();
69+
if (!plan_result.has_value()) {
70+
std::cerr << "Failed to plan files: " << plan_result.error().message << std::endl;
71+
return 1;
72+
}
73+
74+
std::cout << "Scan tasks: " << std::endl;
75+
auto scan_tasks = std::move(plan_result.value());
76+
for (const auto& scan_task : scan_tasks) {
77+
std::cout << " - " << scan_task->data_file()->file_path << std::endl;
78+
}
79+
3580
return 0;
3681
}

src/iceberg/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ set(ICEBERG_SOURCES
4747
type.cc
4848
manifest_reader.cc
4949
manifest_reader_internal.cc
50+
manifest_writer.cc
5051
arrow_c_data_guard_internal.cc
5152
util/murmurhash3_internal.cc
5253
util/timepoint.cc
@@ -115,7 +116,8 @@ if(ICEBERG_BUILD_BUNDLE)
115116
parquet/parquet_data_util.cc
116117
parquet/parquet_reader.cc
117118
parquet/parquet_register.cc
118-
parquet/parquet_schema_util.cc)
119+
parquet/parquet_schema_util.cc
120+
parquet/parquet_writer.cc)
119121

120122
# Libraries to link with exported libiceberg_bundle.{so,a}.
121123
set(ICEBERG_BUNDLE_STATIC_BUILD_INTERFACE_LIBS)

src/iceberg/arrow/arrow_error_transform_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ inline ErrorKind ToErrorKind(const ::arrow::Status& status) {
3030
switch (status.code()) {
3131
case ::arrow::StatusCode::IOError:
3232
return ErrorKind::kIOError;
33+
case ::arrow::StatusCode::NotImplemented:
34+
return ErrorKind::kNotImplemented;
3335
default:
3436
return ErrorKind::kUnknownError;
3537
}

src/iceberg/arrow/arrow_file_io.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
24+
#include "iceberg/file_io.h"
25+
#include "iceberg/iceberg_bundle_export.h"
26+
27+
namespace iceberg::arrow {
28+
29+
ICEBERG_BUNDLE_EXPORT std::unique_ptr<FileIO> MakeMockFileIO();
30+
31+
ICEBERG_BUNDLE_EXPORT std::unique_ptr<FileIO> MakeLocalFileIO();
32+
33+
} // namespace iceberg::arrow

0 commit comments

Comments
 (0)