Repository: deepset-ai/haystack

Issue:
DocumentCleaner does not pass along dataframe
**Describe the bug**
DocumentCleaner does not pass along dataframe

https://github.com/deepset-ai/haystack/blob/main/haystack/components/preprocessors/document_cleaner.py
```
      cleaned_docs.append(Document(content=text, meta=deepcopy(doc.meta), id=doc.id if self.keep_id else ""))
```

Discussion:

Solution patch:
diff --git a/haystack/components/preprocessors/document_cleaner.py b/haystack/components/preprocessors/document_cleaner.py
index d56006130c..29e0757cc4 100644
--- a/haystack/components/preprocessors/document_cleaner.py
+++ b/haystack/components/preprocessors/document_cleaner.py
@@ -38,7 +38,7 @@ class DocumentCleaner:
     ```
     """
 
-    def __init__(
+    def __init__(  # pylint: disable=too-many-positional-arguments
         self,
         remove_empty_lines: bool = True,
         remove_extra_whitespaces: bool = True,
@@ -131,7 +131,17 @@ def run(self, documents: List[Document]):
             if self.remove_repeated_substrings:
                 text = self._remove_repeated_substrings(text)
 
-            cleaned_docs.append(Document(content=text, meta=deepcopy(doc.meta), id=doc.id if self.keep_id else ""))
+            clean_doc = Document(
+                id=doc.id if self.keep_id else "",
+                content=text,
+                dataframe=doc.dataframe,
+                blob=doc.blob,
+                meta=deepcopy(doc.meta),
+                score=doc.score,
+                embedding=doc.embedding,
+                sparse_embedding=doc.sparse_embedding,
+            )
+            cleaned_docs.append(clean_doc)
 
         return {"documents": cleaned_docs}
 
diff --git a/releasenotes/notes/fix-document-cleaner-4e18a63fd7dc2bd9.yaml b/releasenotes/notes/fix-document-cleaner-4e18a63fd7dc2bd9.yaml
new file mode 100644
index 0000000000..144db126ab
--- /dev/null
+++ b/releasenotes/notes/fix-document-cleaner-4e18a63fd7dc2bd9.yaml
@@ -0,0 +1,4 @@
+---
+fixes:
+  - |
+    Fix `DocumentCleaner` not preserving all `Document` fields when run


Test patch:
diff --git a/test/components/preprocessors/test_document_cleaner.py b/test/components/preprocessors/test_document_cleaner.py
index 2c84d5b12d..5f5633a2c4 100644
--- a/test/components/preprocessors/test_document_cleaner.py
+++ b/test/components/preprocessors/test_document_cleaner.py
@@ -5,7 +5,9 @@
 
 import pytest
 
+from pandas import DataFrame
 from haystack import Document
+from haystack.dataclasses import ByteStream, SparseEmbedding
 from haystack.components.preprocessors import DocumentCleaner
 
 
@@ -204,3 +206,33 @@ def test_ascii_only(self):
         cleaner = DocumentCleaner(ascii_only=True, remove_extra_whitespaces=False, remove_empty_lines=False)
         result = cleaner.run(documents=[Document(content=text)])
         assert result["documents"][0].content == expected_text
+
+    def test_other_document_fields_are_not_lost(self):
+        cleaner = DocumentCleaner(keep_id=True)
+        document = Document(
+            content="This is a text with some words. \n"
+            ""
+            "There is a second sentence. \n"
+            ""
+            "And there is a third sentence.\n",
+            dataframe=DataFrame({"col1": [1], "col2": [2]}),
+            blob=ByteStream.from_string("some_data"),
+            meta={"data": 1},
+            score=0.1,
+            embedding=[0.1, 0.2, 0.3],
+            sparse_embedding=SparseEmbedding([0, 2], [0.1, 0.3]),
+        )
+        res = cleaner.run(documents=[document])
+
+        assert len(res) == 1
+        assert len(res["documents"])
+        assert res["documents"][0].id == document.id
+        assert res["documents"][0].content == (
+            "This is a text with some words. There is a second sentence. And there is a third sentence."
+        )
+        assert res["documents"][0].dataframe.equals(document.dataframe)
+        assert res["documents"][0].blob == document.blob
+        assert res["documents"][0].meta == document.meta
+        assert res["documents"][0].score == document.score
+        assert res["documents"][0].embedding == document.embedding
+        assert res["documents"][0].sparse_embedding == document.sparse_embedding