11use crate :: cli:: CatArgs ;
2- use crate :: input:: resolve_inputs_with_config ;
2+ use crate :: input:: resolve_inputs_report ;
33use crate :: output:: OutputConfig ;
44use arrow:: array:: { ArrayRef , RecordBatch , StringArray , UInt32Array , new_null_array} ;
55use arrow:: compute:: { SortColumn , SortOptions , concat_batches, lexsort_to_indices, take} ;
66use arrow:: datatypes:: { DataType , Field , Schema , SchemaRef } ;
7- use indicatif:: { ProgressBar , ProgressStyle } ;
87use parquet:: arrow:: ArrowWriter ;
98use parquet:: arrow:: arrow_reader:: ParquetRecordBatchReaderBuilder ;
109use std:: fs:: File ;
1110use std:: sync:: Arc ;
1211
1312pub fn execute ( args : & CatArgs , output : & mut OutputConfig ) -> miette:: Result < ( ) > {
14- let sources = resolve_inputs_with_config ( & args. files , & output. cloud_config ) ?;
13+ let sp = output. spinner ( "Loading" ) ;
14+ let sources = resolve_inputs_report ( & args. files , & output. cloud_config , & mut |msg| {
15+ sp. set_message ( msg) ;
16+ } ) ?;
17+ sp. finish_and_clear ( ) ;
1518 let out_path = output
1619 . output_path ( )
1720 . ok_or_else ( || miette:: miette!( "cat requires an output file (-o <path>)" ) ) ?
@@ -23,7 +26,6 @@ pub fn execute(args: &CatArgs, output: &mut OutputConfig) -> miette::Result<()>
2326 }
2427
2528 let output_schema: SchemaRef = if args. union_by_name {
26- // unified schema across all files, preserving column order
2729 let mut fields: Vec < Arc < Field > > = Vec :: new ( ) ;
2830 let mut seen_names: Vec < String > = Vec :: new ( ) ;
2931
@@ -44,7 +46,6 @@ pub fn execute(args: &CatArgs, output: &mut OutputConfig) -> miette::Result<()>
4446
4547 Arc :: new ( Schema :: new ( fields) )
4648 } else {
47- // Use schema from first file
4849 let first_file = File :: open ( sources[ 0 ] . path ( ) )
4950 . map_err ( |e| miette:: miette!( "cannot open '{}': {}" , sources[ 0 ] . display_name( ) , e) ) ?;
5051 let first_builder = ParquetRecordBatchReaderBuilder :: try_new ( first_file)
@@ -63,17 +64,7 @@ pub fn execute(args: &CatArgs, output: &mut OutputConfig) -> miette::Result<()>
6364 let mut all_batches: Vec < RecordBatch > = Vec :: new ( ) ;
6465 let mut total_rows: usize = 0 ;
6566
66- let spinner = if output. is_tty && !output. quiet && sources. len ( ) > 1 {
67- let pb = ProgressBar :: new ( sources. len ( ) as u64 ) ;
68- pb. set_style (
69- ProgressStyle :: default_bar ( )
70- . template ( " Concatenating [{bar:20}] {pos}/{len} files" )
71- . unwrap ( ) ,
72- ) ;
73- Some ( pb)
74- } else {
75- None
76- } ;
67+ let progress = output. progress_bar ( "Concatenating" , sources. len ( ) as u64 ) ;
7768
7869 for source in & sources {
7970 let file = File :: open ( source. path ( ) )
@@ -115,13 +106,9 @@ pub fn execute(args: &CatArgs, output: &mut OutputConfig) -> miette::Result<()>
115106
116107 all_batches. push ( final_batch) ;
117108 }
118- if let Some ( ref pb) = spinner {
119- pb. inc ( 1 ) ;
120- }
121- }
122- if let Some ( ref pb) = spinner {
123- pb. finish_and_clear ( ) ;
109+ progress. inc ( 1 ) ;
124110 }
111+ drop ( progress) ;
125112
126113 let write_batches: Vec < RecordBatch > = if let Some ( ref sort_by) = args. sort_by {
127114 if all_batches. is_empty ( ) {
@@ -189,7 +176,6 @@ pub fn execute(args: &CatArgs, output: &mut OutputConfig) -> miette::Result<()>
189176 Ok ( ( ) )
190177}
191178
192- /// Align a batch to a target schema by reordering columns and filling missing ones with nulls.
193179fn align_batch_to_schema (
194180 batch : & RecordBatch ,
195181 file_schema : & SchemaRef ,
@@ -207,7 +193,6 @@ fn align_batch_to_schema(
207193 {
208194 columns. push ( batch. column ( idx) . clone ( ) ) ;
209195 } else {
210- // Column not present in this file — fill with nulls
211196 columns. push ( new_null_array ( target_field. data_type ( ) , num_rows) ) ;
212197 }
213198 }
@@ -216,7 +201,6 @@ fn align_batch_to_schema(
216201 . map_err ( |e| miette:: miette!( "failed to build aligned batch: {}" , e) )
217202}
218203
219- /// Add a `_filename` column to a batch.
220204fn add_filename_column (
221205 batch : & RecordBatch ,
222206 filename : & str ,
0 commit comments