Skip to content

Commit 02eaf8d

Browse files
Add feature flags for metadata providers (#23)
1 parent 4e2edee commit 02eaf8d

13 files changed

+39
-17
lines changed

Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ object_store = { version = "0.12.4", features = ["aws"] }
2121
url = "2.5"
2222
async-trait = "0.1"
2323
tokio = { version = "1", features = ["full"] }
24-
duckdb = { version = "1.4.1", features = ["bundled"] }
2524
futures = "0.3"
2625
tracing = "0.1"
2726
thiserror = "2.0"
2827

29-
# Multi-database metadata providers (optional)
28+
# Metadata providers (optional)
29+
duckdb = { version = "1.4.1", features = ["bundled"], optional = true }
3030
sqlx = { version = "0.8", features = ["runtime-tokio"], optional = true }
3131

3232
[dev-dependencies]
@@ -39,10 +39,13 @@ aws-credential-types = "1.2"
3939
sqllogictest = "0.23"
4040

4141
[features]
42+
default = ["metadata-duckdb"]
43+
4244
# Allow skipping tests that use docker (in CI, macos doesn't support docker).
4345
skip-tests-with-docker = []
4446

4547
# Metadata provider backends
46-
metadata-postgres = ["sqlx", "sqlx/postgres", "sqlx/chrono"]
48+
metadata-duckdb = ["dep:duckdb"]
49+
metadata-postgres = ["dep:sqlx", "sqlx/postgres", "sqlx/chrono"]
4750
# Future: metadata-sqlite = ["sqlx", "sqlx/sqlite", "sqlx/chrono"]
4851
# Future: metadata-mysql = ["sqlx", "sqlx/mysql", "sqlx/chrono"]

examples/basic_query.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
3333
use datafusion::execution::runtime_env::RuntimeEnv;
3434
use datafusion::prelude::*;
35+
#[cfg(feature = "metadata-duckdb")]
36+
use datafusion_ducklake::DuckdbMetadataProvider;
3537
#[cfg(feature = "metadata-postgres")]
3638
use datafusion_ducklake::PostgresMetadataProvider;
37-
use datafusion_ducklake::{
38-
DuckLakeCatalog, DuckdbMetadataProvider, MetadataProvider, register_ducklake_functions,
39-
};
39+
use datafusion_ducklake::{DuckLakeCatalog, MetadataProvider, register_ducklake_functions};
4040
use object_store::ObjectStore;
4141
use object_store::aws::AmazonS3Builder;
4242
use std::env;
@@ -78,11 +78,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
7878
run_query(provider, snapshot_id, sql).await?;
7979
}
8080
} else {
81-
println!("Connecting to DuckDB catalog: {}", catalog_source);
82-
let provider = Arc::new(DuckdbMetadataProvider::new(catalog_source)?);
83-
let snapshot_id = provider.get_current_snapshot()?;
84-
println!("Current snapshot ID: {}", snapshot_id);
85-
run_query(provider, snapshot_id, sql).await?;
81+
#[cfg(feature = "metadata-duckdb")]
82+
{
83+
println!("Connecting to DuckDB catalog: {}", catalog_source);
84+
let provider = Arc::new(DuckdbMetadataProvider::new(catalog_source)?);
85+
let snapshot_id = provider.get_current_snapshot()?;
86+
println!("Current snapshot ID: {}", snapshot_id);
87+
run_query(provider, snapshot_id, sql).await?;
88+
}
89+
90+
#[cfg(not(feature = "metadata-duckdb"))]
91+
{
92+
eprintln!("Error: DuckDB catalog requires the 'metadata-duckdb' feature");
93+
exit(1);
94+
}
8695
}
8796

8897
Ok(())

src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub enum DuckLakeError {
1414
Arrow(#[from] arrow::error::ArrowError),
1515

1616
/// DuckDB error
17+
#[cfg(feature = "metadata-duckdb")]
1718
#[error("DuckDB error: {0}")]
1819
DuckDb(#[from] duckdb::Error),
1920

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ pub mod delete_filter;
4040
pub mod error;
4141
pub mod information_schema;
4242
pub mod metadata_provider;
43-
pub mod metadata_provider_duckdb;
4443
pub mod path_resolver;
4544
pub mod schema;
4645
pub mod table;
4746
pub mod table_functions;
4847
pub mod types;
4948

50-
// Multi-database metadata providers (optional, feature-gated)
49+
// Metadata providers (feature-gated)
50+
#[cfg(feature = "metadata-duckdb")]
51+
pub mod metadata_provider_duckdb;
5152
#[cfg(feature = "metadata-postgres")]
5253
pub mod metadata_provider_postgres;
5354

@@ -58,11 +59,12 @@ pub type Result<T> = std::result::Result<T, DuckLakeError>;
5859
pub use catalog::DuckLakeCatalog;
5960
pub use error::DuckLakeError;
6061
pub use metadata_provider::MetadataProvider;
61-
pub use metadata_provider_duckdb::DuckdbMetadataProvider;
6262
pub use schema::DuckLakeSchema;
6363
pub use table::DuckLakeTable;
6464
pub use table_functions::register_ducklake_functions;
6565

66-
// Re-export multi-database metadata providers (feature-gated)
66+
// Re-export metadata providers (feature-gated)
67+
#[cfg(feature = "metadata-duckdb")]
68+
pub use metadata_provider_duckdb::DuckdbMetadataProvider;
6769
#[cfg(feature = "metadata-postgres")]
6870
pub use metadata_provider_postgres::PostgresMetadataProvider;

tests/common/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "metadata-duckdb")]
12
//! Common test utilities for integration tests
23
//!
34
//! This module provides helper functions to generate DuckLake catalogs

tests/concurrent_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "metadata-duckdb")]
12
//! Concurrent query safety tests
23
//!
34
//! This test suite verifies that DataFusion-DuckLake is thread-safe and can handle

tests/delete_filter_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "metadata-duckdb")]
12
//! Integration tests for delete file filtering
23
//!
34
//! These tests verify that the delete file implementation correctly filters out

tests/hybrid_asyncdb.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "metadata-duckdb")]
12
//! Hybrid AsyncDB adapter for running DuckDB DuckLake tests
23
//!
34
//! This adapter uses a hybrid approach:

tests/information_schema_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "metadata-duckdb")]
12
//! Integration tests for information_schema virtual tables and table functions
23
34
use datafusion::prelude::*;

tests/object_store_integration_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "metadata-duckdb")]
12
//! Integration test for object store support (S3/MinIO)
23
//!
34
//! This test verifies that DataFusion-DuckLake works correctly with object stores

0 commit comments

Comments
 (0)