@@ -228,7 +228,6 @@ class AvroOutputFile(Generic[D]):
228228 encoder : BinaryEncoder
229229 sync_bytes : bytes
230230 writer : Writer
231- records_written : int
232231
233232 def __init__ (
234233 self ,
@@ -248,7 +247,6 @@ def __init__(
248247 else resolve_writer (record_schema = record_schema , file_schema = self .file_schema )
249248 )
250249 self .metadata = metadata
251- self .records_written = 0
252250
253251 def __enter__ (self ) -> AvroOutputFile [D ]:
254252 """
@@ -268,12 +266,6 @@ def __exit__(
268266 self , exctype : Optional [Type [BaseException ]], excinst : Optional [BaseException ], exctb : Optional [TracebackType ]
269267 ) -> None :
270268 """Perform cleanup when exiting the scope of a 'with' statement."""
271- if self .records_written == 0 :
272- # This is very opinionated, as for Iceberg we should not write empty metadata.
273- # The `write_block` method should be called at least once to make sure that we
274- # write the number of blocks and more.
275- raise ValueError ("No records have been written for this Avro file." )
276-
277269 self .output_stream .close ()
278270
279271 def _write_header (self ) -> None :
@@ -286,15 +278,9 @@ def write_block(self, objects: List[D]) -> None:
286278 in_memory = io .BytesIO ()
287279 block_content_encoder = BinaryEncoder (output_stream = in_memory )
288280
289- records_written_in_block = 0
290281 for obj in objects :
291282 self .writer .write (block_content_encoder , obj )
292- records_written_in_block += 1
293-
294- if records_written_in_block == 0 :
295- raise ValueError ("No records have been written in this block." )
296283
297- self .records_written += records_written_in_block
298284 block_content = in_memory .getvalue ()
299285
300286 self .encoder .write_int (len (objects ))
0 commit comments