@@ -141,6 +141,38 @@ public function test_writing_column_statistics(ParquetEngine $engine) : void
141141 \unlink ($ path );
142142 }
143143
144+ #[DataProvider('engine_provider ' )]
145+ public function test_writing_column_statistics_with_null_values (ParquetEngine $ engine ) : void
146+ {
147+ $ schema = Schema::with (
148+ FlatColumn::string ('all_null ' ),
149+ FlatColumn::string ('all_string ' ),
150+ FlatColumn::string ('mixed ' ),
151+ );
152+
153+ $ rows = [
154+ ['all_null ' => null , 'all_string ' => 'a ' , 'mixed ' => 'x ' ],
155+ ['all_null ' => null , 'all_string ' => 'b ' , 'mixed ' => null ],
156+ ['all_null ' => null , 'all_string ' => 'c ' , 'mixed ' => 'z ' ],
157+ ];
158+
159+ $ path = __DIR__ . '/var/test-writer-parquet-null-stats- ' . generate_random_string () . '.parquet ' ;
160+
161+ (new Writer (engine: $ engine ))->write ($ path , $ schema , $ rows );
162+
163+ $ chunks = [];
164+
165+ foreach ((new Reader (engine: $ engine ))->read ($ path )->metadata ()->columnChunks () as $ chunk ) {
166+ $ chunks [$ chunk ->flatPath ()] = $ chunk ;
167+ }
168+
169+ static ::assertSame (3 , $ chunks ['all_null ' ]->statistics ()->nullCount ());
170+ static ::assertSame (0 , $ chunks ['all_string ' ]->statistics ()->nullCount ());
171+ static ::assertSame (1 , $ chunks ['mixed ' ]->statistics ()->nullCount ());
172+
173+ \unlink ($ path );
174+ }
175+
144176 public function test_writing_data_page_v2_statistics () : void
145177 {
146178 $ options = Options::default ()->set (Option::WRITER_VERSION , 2 );
0 commit comments