Skip to content
Draft
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,12 @@ jobs:
- uses: ./.github/actions/setup-prebuild
with:
enable-sccache: "true"

- name: Rust Tests (Windows)
run: |
cargo nextest run --cargo-profile ci --locked --workspace --all-features --no-fail-fast `
--exclude vortex-bench `
--exclude vortex-python --exclude vortex-duckdb `
--exclude vortex-python `
--exclude vortex-fuzz --exclude vortex-cuda --exclude vortex-cuda-ffi `
--exclude vortex-nvcomp --exclude vortex-cub --exclude vortex-test-e2e-cuda --exclude vortex-python-cuda `
--exclude duckdb-bench `
Expand Down
17 changes: 13 additions & 4 deletions scripts/duckdb-r2-resolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ echo "DuckDB $version release=$release"
entries=$(mktemp)
trap 'rm -f "$entries"' EXIT

for archive in \
libduckdb-linux-amd64.zip \
libduckdb-linux-arm64.zip \
libduckdb-osx-universal.zip; do
archives="libduckdb-linux-amd64.zip
libduckdb-linux-arm64.zip
libduckdb-osx-universal.zip"

# Windows archives are only mirrored from DuckDB releases as for now
if [ "$release" = "true" ]; then
archives="$archives
libduckdb-windows-amd64.zip
libduckdb-windows-arm64.zip"
fi

for archive in $archives; do
url="${PUBLIC_BASE_URL}/${ref_dir}/${archive}"
code=$(curl -o /dev/null -s -w '%{http_code}' --head "$url" || echo 000)
if [ "$code" = "200" ]; then
Expand All @@ -47,6 +54,8 @@ for archive in \
*linux-amd64*) runner=ubuntu-latest; os=linux; arch=amd64 ;;
*linux-arm64*) runner=ubuntu-24.04-arm; os=linux; arch=arm64 ;;
*osx-universal*) runner=macos-14; os=osx; arch=universal ;;
*windows-amd64*) runner=ubuntu-latest; os=windows; arch=amd64 ;;
*windows-arm64*) runner=ubuntu-latest; os=windows; arch=arm64 ;;
esac
jq -nc \
--arg archive "$archive" \
Expand Down
4 changes: 3 additions & 1 deletion vortex-duckdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ name = "vortex_duckdb"
path = "src/lib.rs"
crate-type = ["rlib"]

[target.'cfg(unix)'.dependencies]
custom-labels = { workspace = true }

[dependencies]
async-fs = { workspace = true }
bitvec = { workspace = true }
custom-labels = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
kanal = { workspace = true }
Expand Down
25 changes: 20 additions & 5 deletions vortex-duckdb/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
use std::env;
use std::fs;
use std::io;
#[cfg(unix)]
use std::os::unix::fs::symlink;
#[cfg(windows)]
use std::os::windows::fs::symlink_dir as symlink;
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
Expand Down Expand Up @@ -403,6 +406,8 @@ fn download_prebuilt(version: &DuckDBVersion, library_dir: &Path, target: &str)
"aarch64-apple-darwin" | "x86_64-apple-darwin" => ("osx", "universal"),
"x86_64-unknown-linux-gnu" => ("linux", "amd64"),
"aarch64-unknown-linux-gnu" => ("linux", "arm64"),
"x86_64-pc-windows-msvc" => ("windows", "amd64"),
"aarch64-pc-windows-msvc" => ("windows", "arm64"),
_ => {
println!("cargo:error=Unsupported target {target}");
exit(1);
Expand Down Expand Up @@ -570,6 +575,7 @@ fn bindgen_c2rust(crate_dir: &Path, duckdb_include_dir: &Path) {
/// Generate libvortex_duckdb.*
fn compile_cpp(duckdb_include_dir: &Path) {
let mut build = cc::Build::new();

let has_debuginfo = env::var("DEBUG")
.map(|v| !matches!(v.as_str(), "false" | "0" | "none" | ""))
.unwrap_or(false);
Expand All @@ -578,19 +584,26 @@ fn compile_cpp(duckdb_include_dir: &Path) {
} else {
build.define("NDEBUG", None);
}

if build.get_compiler().is_like_msvc() {
build.flag("/W4").include(duckdb_include_dir);
} else {
build
.flags(["-Wall", "-Wextra", "-Wpedantic", "-Werror"])
// We don't want compiler warnings inside duckdb headers, pass as flags
.flag("-isystem")
.flag(duckdb_include_dir);
}

build
.std("c++20")
.flags(["-Wall", "-Wextra", "-Wpedantic", "-Werror"])
.cpp(true)
// Duckdb 1.5.5 uses C++11. spatial_overrides.o uses
// duckdb::ScalarFunctionCatalogEntry::Name which is constexpr but not
// inline. Our code uses C++20 where constexpr implies inline. GCC
// emits this symbol with STB_GNU_UNIQUE and this conflicts on link stage
// in duckdb-vortex where libvortex_duckdb.a is linked statically
.flag_if_supported("-fno-gnu-unique")
// We don't want compiler warnings inside duckdb headers, pass as flags
.flag("-isystem")
.flag(duckdb_include_dir)
.include("include")
.include("cpp/include")
.files(SOURCE_FILES)
Expand Down Expand Up @@ -755,7 +768,9 @@ fn main() {

// Set rpath for binaries built directly from this crate. This is not
// inherited by downstream crates.
println!("cargo:rustc-link-arg=-Wl,-rpath,{library_dir_str}");
if !cfg!(windows) {
println!("cargo:rustc-link-arg=-Wl,-rpath,{library_dir_str}");
}

// Export the library path for downstream crates via the `links` manifest key.
// Downstream crates can access this via `env::var("DEP_DUCKDB_LIB_DIR")` in their build.rs
Expand Down
2 changes: 1 addition & 1 deletion vortex-duckdb/cpp/include/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void duckdb_vx_vector_set_data_ptr(duckdb_vector ffi_vector, void *ptr);
// Converts a duckdb flat vector into a Sequence vector.
void duckdb_vx_sequence_vector(duckdb_vector c_vector, int64_t start, int64_t step, idx_t capacity);

void duckdb_vector_flatten(duckdb_vector vector, unsigned long len);
void duckdb_vector_flatten(duckdb_vector vector, idx_t len);

duckdb_value duckdb_vx_vector_get_value(duckdb_vector ffi_vector, idx_t index);

Expand Down
6 changes: 5 additions & 1 deletion vortex-duckdb/cpp/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ extern "C" duckdb_value duckdb_vx_vector_get_value(duckdb_vector ffi_vector, idx
return reinterpret_cast<duckdb_value>(value.release());
}

void duckdb_vector_flatten(duckdb_vector vector, unsigned long len) {
void duckdb_vector_flatten(duckdb_vector vector, idx_t len) {
auto dvector = reinterpret_cast<Vector *>(vector);
dvector->Flatten(len);
}
Expand All @@ -131,7 +131,11 @@ void duckdb_vx_vector_set_all_valid(duckdb_vector ffi_vector) {
case FSST_VECTOR:
return FSSTVector::Validity(vector).Reset();
default:
#if defined(_MSC_VER) && !defined(__clang__)
__assume(false);
#else
__builtin_unreachable();
#endif
}
}

Expand Down
26 changes: 15 additions & 11 deletions vortex-duckdb/src/table_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;

#[cfg(unix)]
use custom_labels::CURRENT_LABELSET;
use futures::future::BoxFuture;
use itertools::Itertools;
Expand All @@ -32,6 +33,7 @@ use vortex::error::vortex_bail;
use vortex::expr::BoundExpression;
use vortex::expr::Expression;
use vortex::extension::uuid::Uuid;
#[cfg(unix)]
use vortex::metrics::tracing::get_global_labels;
use vortex::scalar::Scalar;
use vortex::scalar_fn::fns::binary::Binary;
Expand Down Expand Up @@ -338,19 +340,21 @@ fn build_partials(
}

pub fn init_local(bind_data: &BindState, global: &GlobalState) -> LocalState {
unsafe {
use custom_labels::sys;

if sys::current().is_null() {
let ls = sys::new(0);
sys::replace(ls);
};
}
#[cfg(unix)]
{
unsafe {
use custom_labels::sys;
if sys::current().is_null() {
let ls = sys::new(0);
sys::replace(ls);
};
}

let global_labels = get_global_labels();
let global_labels = get_global_labels();

for (key, value) in global_labels {
CURRENT_LABELSET.set(key, value);
for (key, value) in global_labels {
CURRENT_LABELSET.set(key, value);
}
}

let partials = build_partials(&global.aggregates, &bind_data.columns, &bind_data.dtype)
Expand Down
Loading