Skip to content

Commit

Permalink
Copy FMDs instead of mutate (#279)
Browse files Browse the repository at this point in the history
Fixes #248
  • Loading branch information
martindurant committed Jan 18, 2018
1 parent 4730530 commit ddea5b7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fastparquet/writer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import print_function

from copy import copy
import json
import re
import struct
Expand Down Expand Up @@ -621,11 +622,10 @@ def make_part_file(f, data, schema, compression=None, fmd=None):
foot_size = write_thrift(f, fmd)
f.write(struct.pack(b"<i", foot_size))
else:
prev = fmd.row_groups
fmd = copy(fmd)
fmd.row_groups = [rg]
foot_size = write_thrift(f, fmd)
f.write(struct.pack(b"<i", foot_size))
fmd.row_groups = prev
f.write(MARKER)
return rg

Expand Down Expand Up @@ -924,10 +924,9 @@ def write_common_metadata(fn, fmd, open_with=default_open,
with open_with(fn, 'wb') as f:
f.write(MARKER)
if no_row_groups:
rgs = fmd.row_groups
fmd = copy(fmd)
fmd.row_groups = []
foot_size = write_thrift(f, fmd)
fmd.row_groups = rgs
else:
foot_size = write_thrift(f, fmd)
f.write(struct.pack(b"<i", foot_size))
Expand Down

0 comments on commit ddea5b7

Please sign in to comment.