Skip to content

Commit 2a225cf

Browse files
authored
Merge pull request #2 from spiraldb/fix-duckdb-extension-build
fix: duckdb extension build
2 parents 808a5b0 + bb04ba9 commit 2a225cf

File tree

14 files changed

+60
-87
lines changed

14 files changed

+60
-87
lines changed

.github/workflows/ExtensionTemplate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- uses: actions/checkout@v4
3535
with:
3636
fetch-depth: 0
37-
submodules: 'true'
37+
submodules: 'recursive'
3838

3939
- name: Checkout DuckDB to version
4040
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
@@ -80,7 +80,7 @@ jobs:
8080
- uses: actions/checkout@v4
8181
with:
8282
fetch-depth: 0
83-
submodules: 'true'
83+
submodules: 'recursive'
8484

8585
- name: Install Ninja
8686
run: brew install ninja
@@ -131,7 +131,7 @@ jobs:
131131
- uses: actions/checkout@v4
132132
with:
133133
fetch-depth: 0
134-
submodules: 'true'
134+
submodules: 'recursive'
135135

136136
- uses: actions/setup-python@v2
137137
with:

.github/workflows/MainDistributionPipeline.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,20 @@
33
#
44
name: Main Extension Distribution Pipeline
55
on:
6-
push:
76
pull_request:
8-
workflow_dispatch:
97

108
concurrency:
119
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }}
1210
cancel-in-progress: true
1311

1412
jobs:
15-
duckdb-next-build:
16-
name: Build extension binaries
17-
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@main
18-
with:
19-
duckdb_version: main
20-
ci_tools_version: main
21-
extension_name: quack
22-
2313
duckdb-stable-build:
2414
name: Build extension binaries
25-
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@v1.2.1
15+
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@6a7a4f24c5999355ab36c0a6835baf891fc9d522
2616
with:
27-
duckdb_version: v1.2.1
28-
ci_tools_version: v1.2.1
29-
extension_name: quack
17+
duckdb_version: v1.2.2
18+
ci_tools_version: 6a7a4f24c5999355ab36c0a6835baf891fc9d522
19+
extension_name: vortex
20+
exclude_archs: "wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools;windows_amd64_mingw;windows_amd64;linux_arm64"
21+
extra_toolchains: "rust"
22+
override_ci_tools_repository: spiraldb/extension-ci-tools

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88
branch = main
99
[submodule "duckdb"]
1010
path = duckdb
11-
url = https://github.com/duckdb/duckdb.git
11+
url = https://github.com/spiraldb/duckdb.git
12+
[submodule "vcpkg"]
13+
path = vcpkg
14+
url = [email protected]:microsoft/vcpkg.git

CMakeLists.txt

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,24 @@ set(TARGET_NAME vortex)
44
project(${TARGET_NAME}_project)
55

66
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7-
set(CMAKE_CXX_STANDARD 20)
7+
set(CMAKE_CXX_STANDARD 17)
88

99
include(FetchContent)
1010
FetchContent_Declare(
1111
Corrosion
1212
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
13-
GIT_TAG v0.5.1
14-
)
15-
FetchContent_Declare(
16-
vcpkg
17-
GIT_REPOSITORY https://github.com/microsoft/vcpkg.git
18-
GIT_TAG 2025.03.19
19-
)
20-
FetchContent_MakeAvailable(Corrosion)
21-
FetchContent_MakeAvailable(vcpkg)
22-
23-
# Install vcpkg dependencies.
24-
execute_process(
25-
COMMAND bash ./bootstrap-vcpkg.sh -disableMetrics
26-
WORKING_DIRECTORY "${vcpkg_SOURCE_DIR}"
27-
RESULT_VARIABLE VCPKG_BOOTSTRAP_RESULT
28-
)
29-
set(VCPKG_INSTALL_DIR "${CMAKE_BINARY_DIR}/vcpkg_installed")
30-
file(MAKE_DIRECTORY "${VCPKG_INSTALL_DIR}")
31-
execute_process(
32-
COMMAND "${vcpkg_SOURCE_DIR}/vcpkg" install --no-print-usage --x-manifest-root=${CMAKE_CURRENT_SOURCE_DIR}/vcpkg --x-install-root=${VCPKG_INSTALL_DIR}
33-
WORKING_DIRECTORY "${vcpkg_SOURCE_DIR}"
13+
GIT_TAG v0.5.2
3414
)
3515

36-
if (APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
37-
set(CMAKE_PREFIX_PATH ${VCPKG_INSTALL_DIR}/arm64-osx)
38-
elseif (APPLE)
39-
set(CMAKE_PREFIX_PATH ${VCPKG_INSTALL_DIR}/x64-osx)
40-
elseif (UNIX AND NOT APPLE)
41-
set(CMAKE_PREFIX_PATH ${VCPKG_INSTALL_DIR}/x64-linux)
42-
endif ()
16+
FetchContent_MakeAvailable(Corrosion)
4317

4418
find_package(Catch2 CONFIG REQUIRED)
4519
find_package(Protobuf CONFIG REQUIRED)
4620
if (APPLE)
47-
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
4821
find_library(SECURITY_FRAMEWORK Security)
4922
endif ()
5023

5124
corrosion_import_crate(MANIFEST_PATH vortex/Cargo.toml
52-
# CORROSION_TOOLS_RUST_TOOLCHAIN "nightly-2025-02-24"
5325
CRATES vortex-ffi
5426
FEATURES duckdb
5527
IMPORTED_CRATES vortex_ffi
@@ -73,13 +45,11 @@ build_loadable_extension(${TARGET_NAME} ${EXTENSION_SOURCES} ${PROTO_SRCS})
7345
target_link_libraries(${EXTENSION_NAME}
7446
vortex_ffi-static
7547
protobuf::libprotobuf
76-
${CORE_FOUNDATION_FRAMEWORK}
7748
${SECURITY_FRAMEWORK}
7849
)
7950
target_link_libraries(${LOADABLE_EXTENSION_NAME}
8051
vortex_ffi-shared
8152
protobuf::libprotobuf
82-
${CORE_FOUNDATION_FRAMEWORK}
8353
${SECURITY_FRAMEWORK}
8454
)
8555

Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
22

3-
# Configuration of extension
43
EXT_NAME=vortex_duckdb
54
EXT_CONFIG=${PROJ_DIR}extension_config.cmake
6-
EXT_FLAGS=-DDISABLE_VPTR_SANITIZER=ON -DOVERRIDE_GIT_DESCRIBE=v1.2.2
7-
EXT_FLAGS += -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0
5+
EXT_FLAGS=-DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 -DOVERRIDE_GIT_DESCRIBE=v1.2.2
86

9-
export MACOSX_DEPLOYMENT_TARGET=13.0
10-
export VCPKG_OSX_DEPLOYMENT_TARGET=13.0
7+
export MACOSX_DEPLOYMENT_TARGET=12.0
8+
export VCPKG_OSX_DEPLOYMENT_TARGET=12.0
119
export VCPKG_FEATURE_FLAGS=-binarycaching
10+
export VCPKG_TOOLCHAIN_PATH := ${PROJ_DIR}vcpkg/scripts/buildsystems/vcpkg.cmake
1211

13-
# Include the Makefile from extension-ci-tools
1412
include extension-ci-tools/makefiles/duckdb_extension.Makefile

duckdb

src/include/vortex_error.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include "vortex.hpp"
44

55
inline void HandleError(vx_error *error) {
6-
if (error != nullptr && error->code != 0) {
7-
auto msg = std::string(error->message);
6+
if (error != nullptr) {
7+
auto msg = std::string(vx_error_get_message(error));
88
vx_error_free(error);
99
throw duckdb::InvalidInputException(msg);
1010
}
11-
}
11+
}

src/vortex_extension.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include "duckdb/main/extension_util.hpp"
66
#include "vortex_extension.hpp"
77

8-
#include <filesystem>
9-
108
#include "vortex_write.hpp"
119
#include "vortex_scan.hpp"
1210

src/vortex_scan.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
#include "duckdb/common/multi_file_reader.hpp"
66
#include "duckdb/function/table_function.hpp"
77
#include "duckdb/main/extension_util.hpp"
8+
#include "duckdb/common/file_system.hpp"
89
#include "vortex_extension.hpp"
910

10-
#include <filesystem>
11+
#include <regex>
1112

1213
#include "vortex_common.hpp"
1314
#include "expr/expr.hpp"
@@ -150,23 +151,20 @@ static void ExtractVortexSchema(const vx_dtype *file_dtype, vector<LogicalType>
150151
}
151152
}
152153

153-
std::string EnsureFileProtocol(const std::string &path) {
154-
auto absolute_path = path;
155-
const std::string prefix = "file://";
154+
const std::regex schema_prefix = std::regex("^[^/]*:\\/\\/.*$");
156155

157-
std::filesystem::path p = absolute_path;
158-
if (!p.is_absolute()) {
159-
try {
160-
absolute_path = absolute(p).string();
161-
} catch (const std::exception &e) {
162-
throw InternalException(std::string("Error making path absolute: ") + e.what());
163-
}
156+
std::string EnsureFileProtocol(FileSystem &fs, const std::string &path) {
157+
// If the path is a URL then don't change it, otherwise try to make the path an absolute path
158+
if (std::regex_match(path, schema_prefix)) {
159+
return path;
164160
}
165161

166-
// Check if the string already starts with "file://"
167-
if (absolute_path.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), absolute_path.begin())) {
168-
return absolute_path;
162+
const std::string prefix = "file://";
163+
if (fs.IsPathAbsolute(path)) {
164+
return prefix + path;
169165
}
166+
167+
const auto absolute_path = fs.JoinPath(fs.GetWorkingDirectory(), path);
170168
return prefix + absolute_path;
171169
}
172170

@@ -209,13 +207,14 @@ static void VerifyNewFile(const VortexBindData &bind_data, vector<LogicalType> &
209207
}
210208
}
211209

212-
static unique_ptr<VortexFileReader> OpenFileAndVerify(const std::string &filename, const VortexBindData &bind_data) {
210+
static unique_ptr<VortexFileReader> OpenFileAndVerify(FileSystem &fs, const std::string &filename,
211+
const VortexBindData &bind_data) {
213212
auto new_column_names = vector<string>();
214213
new_column_names.reserve(bind_data.column_names.size());
215214
auto new_column_types = vector<LogicalType>();
216215
new_column_names.reserve(bind_data.columns_types.size());
217216

218-
auto file = OpenFile(EnsureFileProtocol(filename), new_column_types, new_column_names);
217+
auto file = OpenFile(EnsureFileProtocol(fs, filename), new_column_types, new_column_names);
219218
VerifyNewFile(bind_data, new_column_types, new_column_names);
220219
return file;
221220
}
@@ -268,7 +267,7 @@ static void VortexScanFunction(ClientContext &context, TableFunctionInput &data,
268267
}
269268

270269
auto file_name = global_state.expanded_files[file_idx];
271-
auto file = OpenFileAndVerify(file_name, bind_data);
270+
auto file = OpenFileAndVerify(FileSystem::GetFileSystem(context), file_name, bind_data);
272271

273272
slot.array_stream = OpenArrayStream(bind_data, global_state, file.get());
274273
}
@@ -309,7 +308,7 @@ static unique_ptr<FunctionData> VortexBind(ClientContext &context, TableFunction
309308
auto vec = duckdb::vector<string> {input.inputs[0].GetValue<string>()};
310309
result->file_list = make_shared_ptr<GlobMultiFileList>(context, vec, FileGlobOptions::DISALLOW_EMPTY);
311310

312-
auto filename = EnsureFileProtocol(result->file_list->GetFirstFile());
311+
auto filename = EnsureFileProtocol(FileSystem::GetFileSystem(context), result->file_list->GetFirstFile());
313312

314313
result->initial_file = OpenFile(filename, column_types, column_names);
315314

@@ -366,7 +365,7 @@ void RegisterVortexScanFunction(DatabaseInstance &instance) {
366365

367366
// Most expressions are extracted from `PushdownComplexFilter`, the final filters come from `input.filters`.
368367
vector<vortex::expr::Expr *> conjuncts;
369-
std::ranges::copy(bind.conjuncts, std::back_inserter(conjuncts));
368+
std::copy(bind.conjuncts.begin(), bind.conjuncts.end(), std::back_inserter(conjuncts));
370369
CreateFilterExpression(*bind.arena, bind.column_names, input.filters, input.column_ids, conjuncts);
371370

372371
auto column_names = std::vector<char const *>();

0 commit comments

Comments
 (0)