Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/ExtensionTemplate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'true'
submodules: 'recursive'

- name: Checkout DuckDB to version
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'true'
submodules: 'recursive'

- name: Install Ninja
run: brew install ninja
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'true'
submodules: 'recursive'

- uses: actions/setup-python@v2
with:
Expand Down
21 changes: 7 additions & 14 deletions .github/workflows/MainDistributionPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,20 @@
#
name: Main Extension Distribution Pipeline
on:
push:
pull_request:
workflow_dispatch:

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

jobs:
duckdb-next-build:
name: Build extension binaries
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@main
with:
duckdb_version: main
ci_tools_version: main
extension_name: quack

duckdb-stable-build:
name: Build extension binaries
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@v1.2.1
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@6a7a4f24c5999355ab36c0a6835baf891fc9d522
with:
duckdb_version: v1.2.1
ci_tools_version: v1.2.1
extension_name: quack
duckdb_version: v1.2.2
ci_tools_version: 6a7a4f24c5999355ab36c0a6835baf891fc9d522
extension_name: vortex
exclude_archs: "wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools;windows_amd64_mingw;windows_amd64;linux_arm64"
extra_toolchains: "rust"
override_ci_tools_repository: spiraldb/extension-ci-tools
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
branch = main
[submodule "duckdb"]
path = duckdb
url = https://github.com/duckdb/duckdb.git
url = https://github.com/spiraldb/duckdb.git
[submodule "vcpkg"]
path = vcpkg
url = [email protected]:microsoft/vcpkg.git
36 changes: 3 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,24 @@ set(TARGET_NAME vortex)
project(${TARGET_NAME}_project)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)

include(FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.5.1
)
FetchContent_Declare(
vcpkg
GIT_REPOSITORY https://github.com/microsoft/vcpkg.git
GIT_TAG 2025.03.19
)
FetchContent_MakeAvailable(Corrosion)
FetchContent_MakeAvailable(vcpkg)

# Install vcpkg dependencies.
execute_process(
COMMAND bash ./bootstrap-vcpkg.sh -disableMetrics
WORKING_DIRECTORY "${vcpkg_SOURCE_DIR}"
RESULT_VARIABLE VCPKG_BOOTSTRAP_RESULT
)
set(VCPKG_INSTALL_DIR "${CMAKE_BINARY_DIR}/vcpkg_installed")
file(MAKE_DIRECTORY "${VCPKG_INSTALL_DIR}")
execute_process(
COMMAND "${vcpkg_SOURCE_DIR}/vcpkg" install --no-print-usage --x-manifest-root=${CMAKE_CURRENT_SOURCE_DIR}/vcpkg --x-install-root=${VCPKG_INSTALL_DIR}
WORKING_DIRECTORY "${vcpkg_SOURCE_DIR}"
GIT_TAG v0.5.2
)

if (APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
set(CMAKE_PREFIX_PATH ${VCPKG_INSTALL_DIR}/arm64-osx)
elseif (APPLE)
set(CMAKE_PREFIX_PATH ${VCPKG_INSTALL_DIR}/x64-osx)
elseif (UNIX AND NOT APPLE)
set(CMAKE_PREFIX_PATH ${VCPKG_INSTALL_DIR}/x64-linux)
endif ()
FetchContent_MakeAvailable(Corrosion)

find_package(Catch2 CONFIG REQUIRED)
find_package(Protobuf CONFIG REQUIRED)
if (APPLE)
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
find_library(SECURITY_FRAMEWORK Security)
endif ()

corrosion_import_crate(MANIFEST_PATH vortex/Cargo.toml
# CORROSION_TOOLS_RUST_TOOLCHAIN "nightly-2025-02-24"
CRATES vortex-ffi
FEATURES duckdb
IMPORTED_CRATES vortex_ffi
Expand All @@ -73,13 +45,11 @@ build_loadable_extension(${TARGET_NAME} ${EXTENSION_SOURCES} ${PROTO_SRCS})
target_link_libraries(${EXTENSION_NAME}
vortex_ffi-static
protobuf::libprotobuf
${CORE_FOUNDATION_FRAMEWORK}
${SECURITY_FRAMEWORK}
)
target_link_libraries(${LOADABLE_EXTENSION_NAME}
vortex_ffi-shared
protobuf::libprotobuf
${CORE_FOUNDATION_FRAMEWORK}
${SECURITY_FRAMEWORK}
)

Expand Down
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

# Configuration of extension
EXT_NAME=vortex_duckdb
EXT_CONFIG=${PROJ_DIR}extension_config.cmake
EXT_FLAGS=-DDISABLE_VPTR_SANITIZER=ON -DOVERRIDE_GIT_DESCRIBE=v1.2.2
EXT_FLAGS += -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0
EXT_FLAGS=-DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 -DOVERRIDE_GIT_DESCRIBE=v1.2.2

export MACOSX_DEPLOYMENT_TARGET=13.0
export VCPKG_OSX_DEPLOYMENT_TARGET=13.0
export MACOSX_DEPLOYMENT_TARGET=12.0
export VCPKG_OSX_DEPLOYMENT_TARGET=12.0
export VCPKG_FEATURE_FLAGS=-binarycaching
export VCPKG_TOOLCHAIN_PATH := ${PROJ_DIR}vcpkg/scripts/buildsystems/vcpkg.cmake

# Include the Makefile from extension-ci-tools
include extension-ci-tools/makefiles/duckdb_extension.Makefile
2 changes: 1 addition & 1 deletion duckdb
6 changes: 3 additions & 3 deletions src/include/vortex_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "vortex.hpp"

inline void HandleError(vx_error *error) {
if (error != nullptr && error->code != 0) {
auto msg = std::string(error->message);
if (error != nullptr) {
auto msg = std::string(vx_error_get_message(error));
vx_error_free(error);
throw duckdb::InvalidInputException(msg);
}
}
}
2 changes: 0 additions & 2 deletions src/vortex_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include "duckdb/main/extension_util.hpp"
#include "vortex_extension.hpp"

#include <filesystem>

#include "vortex_write.hpp"
#include "vortex_scan.hpp"

Expand Down
37 changes: 18 additions & 19 deletions src/vortex_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#include "duckdb/common/multi_file_reader.hpp"
#include "duckdb/function/table_function.hpp"
#include "duckdb/main/extension_util.hpp"
#include "duckdb/common/file_system.hpp"
#include "vortex_extension.hpp"

#include <filesystem>
#include <regex>

#include "vortex_common.hpp"
#include "expr/expr.hpp"
Expand Down Expand Up @@ -150,23 +151,20 @@ static void ExtractVortexSchema(const vx_dtype *file_dtype, vector<LogicalType>
}
}

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

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

// Check if the string already starts with "file://"
if (absolute_path.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), absolute_path.begin())) {
return absolute_path;
const std::string prefix = "file://";
if (fs.IsPathAbsolute(path)) {
return prefix + path;
}

const auto absolute_path = fs.JoinPath(fs.GetWorkingDirectory(), path);
return prefix + absolute_path;
}

Expand Down Expand Up @@ -209,13 +207,14 @@ static void VerifyNewFile(const VortexBindData &bind_data, vector<LogicalType> &
}
}

static unique_ptr<VortexFileReader> OpenFileAndVerify(const std::string &filename, const VortexBindData &bind_data) {
static unique_ptr<VortexFileReader> OpenFileAndVerify(FileSystem &fs, const std::string &filename,
const VortexBindData &bind_data) {
auto new_column_names = vector<string>();
new_column_names.reserve(bind_data.column_names.size());
auto new_column_types = vector<LogicalType>();
new_column_names.reserve(bind_data.columns_types.size());

auto file = OpenFile(EnsureFileProtocol(filename), new_column_types, new_column_names);
auto file = OpenFile(EnsureFileProtocol(fs, filename), new_column_types, new_column_names);
VerifyNewFile(bind_data, new_column_types, new_column_names);
return file;
}
Expand Down Expand Up @@ -268,7 +267,7 @@ static void VortexScanFunction(ClientContext &context, TableFunctionInput &data,
}

auto file_name = global_state.expanded_files[file_idx];
auto file = OpenFileAndVerify(file_name, bind_data);
auto file = OpenFileAndVerify(FileSystem::GetFileSystem(context), file_name, bind_data);

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

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

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

Expand Down Expand Up @@ -366,7 +365,7 @@ void RegisterVortexScanFunction(DatabaseInstance &instance) {

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

auto column_names = std::vector<char const *>();
Expand Down
1 change: 1 addition & 0 deletions vcpkg
Submodule vcpkg added at d6995a
14 changes: 14 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dependencies": [{ "name": "catch2" }, { "name": "protobuf" } ],
"vcpkg-configuration": {
"registries": [
{
"kind": "git",
"repository": "https://github.com/duckdb/vcpkg-duckdb-ports",
"baseline": "c8f9d504986e76dbcd4585a34028ff00e251f40f",
"packages": [ "vcpkg-cmake" ]
}
]
},
"builtin-baseline" : "5e5d0e1cd7785623065e77eff011afdeec1a3574"
}
3 changes: 0 additions & 3 deletions vcpkg/vcpkg.json

This file was deleted.

2 changes: 1 addition & 1 deletion vortex
Loading