forked from delta-io/delta-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable passing storage options to Delta table builder via DataF…
…usion's CREATE EXTERNAL TABLE (delta-io#1043) # Description We've recently added Delta table support to [Seafowl](https://github.com/splitgraph/seafowl) using delta-rs, which utilizes the new `OPTIONS` clause in sqlparser/DataFusion. It allows propagating a set of key/values down to the `DeltaTableBuilder`, which in turn can use those to instantiate a corresponding object store client. This means someone can now define a delta table without relying on env vars as: ```sql CREATE EXTERNAL TABLE my_delta STORED AS DELTATABLE OPTIONS ('AWS_ACCESS_KEY_ID' 'secret', 'AWS_SECRET_ACCESS_KEY' 'also_secret', 'AWS_REGION' 'eu-west-3') LOCATION 's3://my-bucket/my-delta-table/' ``` I've also changed the existing datafusion integration tests to use this approach to exercise it. I'm not sure whether it makes sense to merge this PR upstream, but opening this PR just in case it does. # Related Issue(s) Didn't find any related issues. # Documentation
- Loading branch information
1 parent
6109d4b
commit 94423ba
Showing
7 changed files
with
71 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use datafusion::datasource::datasource::TableProviderFactory; | ||
use datafusion::execution::context::SessionContext; | ||
use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv}; | ||
use datafusion::prelude::SessionConfig; | ||
use deltalake::delta_datafusion::DeltaTableFactory; | ||
use std::collections::HashMap; | ||
use std::sync::Arc; | ||
|
||
pub fn context_with_delta_table_factory() -> SessionContext { | ||
let mut table_factories: HashMap<String, Arc<dyn TableProviderFactory>> = HashMap::new(); | ||
table_factories.insert("DELTATABLE".to_string(), Arc::new(DeltaTableFactory {})); | ||
let cfg = RuntimeConfig::new().with_table_factories(table_factories); | ||
let env = RuntimeEnv::new(cfg).unwrap(); | ||
let ses = SessionConfig::new(); | ||
SessionContext::with_config_rt(ses, Arc::new(env)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters