From dcc737205f984879dd2003e3a840dcb8abca3cff Mon Sep 17 00:00:00 2001 From: Steinthor Palsson Date: Sun, 12 Feb 2023 00:12:24 -0500 Subject: [PATCH] Fix current columns and new columns referencing the same object --- dlt/common/data_writers/buffered.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlt/common/data_writers/buffered.py b/dlt/common/data_writers/buffered.py index 509723ea5f..51f2f07247 100644 --- a/dlt/common/data_writers/buffered.py +++ b/dlt/common/data_writers/buffered.py @@ -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 @@ -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) @@ -115,4 +117,4 @@ def _flush_and_close_file(self) -> None: def _ensure_open(self) -> None: if self._closed: - raise BufferedDataWriterClosed(self._file_name) \ No newline at end of file + raise BufferedDataWriterClosed(self._file_name)