-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add testcontainer to verify s3 access
- Loading branch information
1 parent
1406be3
commit cb82c7b
Showing
12 changed files
with
182 additions
and
19 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,86 @@ | ||
mod common; | ||
|
||
#[cfg(test)] | ||
#[cfg(feature = "standalone")] | ||
#[cfg(feature = "testcontainers")] | ||
mod standalone { | ||
|
||
use ballista::extension::SessionContextExt; | ||
use datafusion::{assert_batches_eq, prelude::SessionContext}; | ||
use datafusion::{ | ||
error::DataFusionError, | ||
execution::{ | ||
runtime_env::{RuntimeConfig, RuntimeEnv}, | ||
SessionStateBuilder, | ||
}, | ||
}; | ||
use std::sync::Arc; | ||
use testcontainers_modules::testcontainers::runners::AsyncRunner; | ||
|
||
#[tokio::test] | ||
async fn should_execute_sql_write() -> datafusion::error::Result<()> { | ||
let container = crate::common::create_minio_container(); | ||
let node = container.start().await.unwrap(); | ||
// tokio::time::sleep(Duration::from_secs(300)).await; | ||
node.exec(crate::common::create_bucket_command()) | ||
.await | ||
.unwrap(); | ||
|
||
let port = node.get_host_port_ipv4(9000).await.unwrap(); | ||
//let port = 9000; | ||
|
||
let object_store = crate::common::create_s3_store(port) | ||
.map_err(|e| DataFusionError::External(e.into()))?; | ||
|
||
let test_data = crate::common::example_test_data(); | ||
let config = RuntimeConfig::new(); | ||
let runtime_env = RuntimeEnv::new(config)?; | ||
|
||
runtime_env.register_object_store( | ||
&format!("s3://{}", crate::common::BUCKET) | ||
.as_str() | ||
.try_into() | ||
.unwrap(), | ||
Arc::new(object_store), | ||
); | ||
let state = SessionStateBuilder::new() | ||
.with_runtime_env(runtime_env.into()) | ||
.build(); | ||
|
||
let ctx: SessionContext = SessionContext::standalone_with_state(state).await?; | ||
ctx.register_parquet( | ||
"test", | ||
&format!("{test_data}/alltypes_plain.parquet"), | ||
Default::default(), | ||
) | ||
.await?; | ||
|
||
let write_dir_path = "s3://ballista/write_test.parquet"; | ||
|
||
ctx.sql("select * from test") | ||
.await? | ||
.write_parquet(write_dir_path, Default::default(), Default::default()) | ||
.await?; | ||
|
||
ctx.register_parquet("written_table", write_dir_path, Default::default()) | ||
.await?; | ||
|
||
let result = ctx | ||
.sql("select id, string_col, timestamp_col from written_table where id > 4") | ||
.await? | ||
.collect() | ||
.await?; | ||
let expected = [ | ||
"+----+------------+---------------------+", | ||
"| id | string_col | timestamp_col |", | ||
"+----+------------+---------------------+", | ||
"| 5 | 31 | 2009-03-01T00:01:00 |", | ||
"| 6 | 30 | 2009-04-01T00:00:00 |", | ||
"| 7 | 31 | 2009-04-01T00:01:00 |", | ||
"+----+------------+---------------------+", | ||
]; | ||
|
||
assert_batches_eq!(expected, &result); | ||
Ok(()) | ||
} | ||
} |
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
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