@@ -42,3 +42,60 @@ async fn test_deltalake() {
4242 vec![ "+----+" , "| id |" , "+----+" , "| 5 |" , "| 7 |" , "| 9 |" , "+----+" ]
4343 ) ;
4444}
45+
46+ #[ cfg( feature = "s3" ) ]
47+ #[ tokio:: test( flavor = "multi_thread" ) ]
48+ async fn test_deltalake_s3 ( ) {
49+ use assert_cmd:: Command ;
50+ use std:: io:: Write ;
51+
52+ use crate :: { cli_cases:: contains_str, config:: TestConfigBuilder } ;
53+
54+ let tempdir = tempfile:: tempdir ( ) . unwrap ( ) ;
55+ let ddl_path = tempdir. path ( ) . join ( "my_ddl.sql" ) ;
56+ let mut file = std:: fs:: File :: create ( ddl_path. clone ( ) ) . unwrap ( ) ;
57+ let ddl = "CREATE EXTERNAL TABLE delta_tbl STORED AS DELTATABLE LOCATION 's3://test/deltalake/simple_table';" ;
58+ file. write_all ( ddl. as_bytes ( ) ) . unwrap ( ) ;
59+ file. flush ( ) . unwrap ( ) ;
60+
61+ // Create a temp db directory to avoid conflicts with existing db files
62+ let db_dir = tempdir. path ( ) . join ( "db" ) ;
63+ std:: fs:: create_dir ( & db_dir) . unwrap ( ) ;
64+
65+ let mut config_builder = TestConfigBuilder :: default ( ) ;
66+ config_builder. with_ddl_path ( "cli" , ddl_path) ;
67+ config_builder. with_db_path ( & format ! ( "file://{}" , db_dir. display( ) ) ) ;
68+ config_builder. with_s3_object_store (
69+ "cli" ,
70+ "s3" ,
71+ "test" ,
72+ "s3://test" ,
73+ "http://localhost:4566" ,
74+ "LSIAQAAAAAAVNCBMPNSG" ,
75+ "5555555555555555555555555555555555555555" ,
76+ true ,
77+ ) ;
78+ let config = config_builder. build ( "my_config.toml" ) ;
79+
80+ let assert = Command :: cargo_bin ( "dft" )
81+ . unwrap ( )
82+ . arg ( "--config" )
83+ . arg ( config. path )
84+ . arg ( "--run-ddl" )
85+ . arg ( "-c" )
86+ . arg ( "SELECT id FROM delta_tbl ORDER BY id" )
87+ . assert ( )
88+ . success ( ) ;
89+
90+ let expected = r#"
91+ +----+
92+ | id |
93+ +----+
94+ | 5 |
95+ | 7 |
96+ | 9 |
97+ +----+
98+ "# ;
99+
100+ assert. stdout ( contains_str ( expected) ) ;
101+ }
0 commit comments