Skip to content

Commit

Permalink
Merge pull request #127 from steinitzu/fix/nullable-columns-error-126
Browse files Browse the repository at this point in the history
Fix current columns and new columns referencing the same object
  • Loading branch information
rudolfix authored Feb 14, 2023
2 parents e128552 + dcc7372 commit 566093c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dlt/common/data_writers/buffered.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import List, IO, Any

from copy import deepcopy

from dlt.common.utils import uniq_id
from dlt.common.typing import TDataItem, TDataItems
from dlt.common.data_writers import TLoaderFileFormat
Expand Down Expand Up @@ -54,7 +56,7 @@ def write_data_item(self, item: TDataItems, columns: TTableSchemaColumns) -> Non
if self._writer and not self._writer.data_format().supports_schema_changes and len(columns) != len(self._current_columns):
self._rotate_file()
# until the first chunk is written we can change the columns schema freely
self._current_columns = columns
self._current_columns = deepcopy(columns)
if isinstance(item, List):
# items coming in single list will be written together, not matter how many are there
self._buffered_items.extend(item)
Expand Down Expand Up @@ -115,4 +117,4 @@ def _flush_and_close_file(self) -> None:

def _ensure_open(self) -> None:
if self._closed:
raise BufferedDataWriterClosed(self._file_name)
raise BufferedDataWriterClosed(self._file_name)

0 comments on commit 566093c

Please sign in to comment.