@@ -101,12 +101,11 @@ async fn run_tests() -> Result<()> {
101
101
SpawnedTask :: spawn ( async move {
102
102
let file_path = test_file. relative_path . clone ( ) ;
103
103
let start = datafusion:: common:: instant:: Instant :: now ( ) ;
104
- if options. complete {
105
- run_complete_file ( test_file) . await ?;
106
- } else if options. postgres_runner {
107
- run_test_file_with_postgres ( test_file) . await ?;
108
- } else {
109
- run_test_file ( test_file) . await ?;
104
+ match ( options. postgres_runner , options. complete ) {
105
+ ( false , false ) => run_test_file ( test_file) . await ?,
106
+ ( false , true ) => run_complete_file ( test_file) . await ?,
107
+ ( true , false ) => run_test_file_with_postgres ( test_file) . await ?,
108
+ ( true , true ) => run_complete_file_with_postgres ( test_file) . await ?,
110
109
}
111
110
println ! ( "Executed {:?}. Took {:?}" , file_path, start. elapsed( ) ) ;
112
111
Ok ( ( ) ) as Result < ( ) >
@@ -227,6 +226,41 @@ async fn run_complete_file(test_file: TestFile) -> Result<()> {
227
226
} )
228
227
}
229
228
229
+ #[ cfg( feature = "postgres" ) ]
230
+ async fn run_complete_file_with_postgres ( test_file : TestFile ) -> Result < ( ) > {
231
+ use datafusion_sqllogictest:: Postgres ;
232
+ let TestFile {
233
+ path,
234
+ relative_path,
235
+ } = test_file;
236
+ info ! (
237
+ "Using complete mode to complete with Postgres runner: {}" ,
238
+ path. display( )
239
+ ) ;
240
+ setup_scratch_dir ( & relative_path) ?;
241
+ let mut runner =
242
+ sqllogictest:: Runner :: new ( || Postgres :: connect ( relative_path. clone ( ) ) ) ;
243
+ let col_separator = " " ;
244
+ runner
245
+ . update_test_file (
246
+ path,
247
+ col_separator,
248
+ value_validator,
249
+ strict_column_validator,
250
+ )
251
+ . await
252
+ // Can't use e directly because it isn't marked Send, so turn it into a string.
253
+ . map_err ( |e| {
254
+ DataFusionError :: Execution ( format ! ( "Error completing {relative_path:?}: {e}" ) )
255
+ } )
256
+ }
257
+
258
+ #[ cfg( not( feature = "postgres" ) ) ]
259
+ async fn run_complete_file_with_postgres ( _test_file : TestFile ) -> Result < ( ) > {
260
+ use datafusion_common:: plan_err;
261
+ plan_err ! ( "Can not run with postgres as postgres feature is not enabled" )
262
+ }
263
+
230
264
/// Represents a parsed test file
231
265
#[ derive( Debug ) ]
232
266
struct TestFile {
0 commit comments