@@ -113,6 +113,7 @@ mod tests {
113113 } ;
114114 use datafusion_execution:: config:: SessionConfig ;
115115
116+ use datafusion_expr:: Partitioning ;
116117 use tempfile:: { tempdir, TempDir } ;
117118
118119 #[ tokio:: test]
@@ -216,6 +217,85 @@ mod tests {
216217 Ok ( ( ) )
217218 }
218219
220+ #[ tokio:: test]
221+ async fn write_multiple_file_parquet_no_extensions ( ) -> Result < ( ) > {
222+ let ctx = SessionContext :: new ( ) ;
223+ let df = ctx. read_batch ( RecordBatch :: try_new (
224+ Arc :: new ( Schema :: new ( vec ! [
225+ Field :: new( "purchase_id" , DataType :: Int32 , false ) ,
226+ Field :: new( "price" , DataType :: Float32 , false ) ,
227+ Field :: new( "quantity" , DataType :: Int32 , false ) ,
228+ ] ) ) ,
229+ vec ! [
230+ Arc :: new( Int32Array :: from( vec![ 1 , 2 , 3 , 4 , 5 ] ) ) ,
231+ Arc :: new( Float32Array :: from( vec![ 1.12 , 3.40 , 2.33 , 9.10 , 6.66 ] ) ) ,
232+ Arc :: new( Int32Array :: from( vec![ 1 , 3 , 2 , 4 , 3 ] ) ) ,
233+ ] ,
234+ ) ?) ?;
235+
236+ // Repartition to have the desired.
237+ let partitioned_df = df. repartition ( Partitioning :: RoundRobinBatch ( 2 ) ) ?;
238+ let tmp_dir = tempdir ( ) ?;
239+ let path = tmp_dir
240+ . path ( )
241+ . join ( "no_ext_parquet" )
242+ . to_str ( )
243+ . unwrap ( )
244+ . to_string ( ) ;
245+
246+ let options = DataFrameWriteOptions :: new ( ) ;
247+
248+ partitioned_df. write_parquet ( & path, options, None ) . await ?;
249+
250+ let test_path = std:: path:: Path :: new ( & path) ;
251+ assert_eq ! (
252+ test_path. is_dir( ) ,
253+ true ,
254+ "No extension and default DataFrameWriteOptons should have yielded a dir."
255+ ) ;
256+
257+ Ok ( ( ) )
258+ }
259+
260+ #[ tokio:: test]
261+ async fn write_single_file_parquet_no_extensions ( ) -> Result < ( ) > {
262+ let ctx = SessionContext :: new ( ) ;
263+ let df = ctx. read_batch ( RecordBatch :: try_new (
264+ Arc :: new ( Schema :: new ( vec ! [
265+ Field :: new( "purchase_id" , DataType :: Int32 , false ) ,
266+ Field :: new( "price" , DataType :: Float32 , false ) ,
267+ Field :: new( "quantity" , DataType :: Int32 , false ) ,
268+ ] ) ) ,
269+ vec ! [
270+ Arc :: new( Int32Array :: from( vec![ 1 , 2 , 3 , 4 , 5 ] ) ) ,
271+ Arc :: new( Float32Array :: from( vec![ 1.12 , 3.40 , 2.33 , 9.10 , 6.66 ] ) ) ,
272+ Arc :: new( Int32Array :: from( vec![ 1 , 3 , 2 , 4 , 3 ] ) ) ,
273+ ] ,
274+ ) ?) ?;
275+ // Repartition to have
276+ let partitioned_df = df. repartition ( Partitioning :: RoundRobinBatch ( 2 ) ) ?;
277+ let tmp_dir = tempdir ( ) ?;
278+ let path = tmp_dir
279+ . path ( )
280+ . join ( "no_ext_parquet" )
281+ . to_str ( )
282+ . unwrap ( )
283+ . to_string ( ) ;
284+
285+ let options = DataFrameWriteOptions :: new ( ) . with_single_file_output ( true ) ;
286+
287+ partitioned_df. write_parquet ( & path, options, None ) . await ?;
288+
289+ let test_path = std:: path:: Path :: new ( & path) ;
290+ assert_eq ! (
291+ test_path. is_file( ) ,
292+ true ,
293+ "No extension and DataFrameWriteOptons::with_single_file_output(true) should have yielded a single file."
294+ ) ;
295+
296+ Ok ( ( ) )
297+ }
298+
219299 #[ tokio:: test]
220300 async fn read_from_different_file_extension ( ) -> Result < ( ) > {
221301 let ctx = SessionContext :: new ( ) ;
0 commit comments