You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rebases onto main to recover the 0.3.0 release entries that were rolled
back on the original branch, and applies the review feedback the user-
side review surfaced.
Operator
- Replace the temp-file dance for PDF/DOCX bytes with in-memory streams.
``pypdf.PdfReader`` and ``docx.Document`` both accept binary streams, so
``source_bytes`` now goes through ``io.BytesIO`` directly. No more
``NamedTemporaryFile(delete=False)`` + ``os.unlink``.
- Add ``encoding`` and ``encoding_errors`` parameters for non-UTF-8 input
(Windows-1252 CSVs, files with a leading byte-order mark, ...). Failed
decodes raise a ``ValueError`` that includes the offending file path so
directory-mode runs are diagnosable.
- Add ``json_text_field``: when set, the named key on each JSON item
becomes the embedding text and every other key lands in ``metadata``.
When unset, JSON dicts are flattened to ``"k: v, k: v"`` (matches the
CSV parser) instead of being dumped back to JSON syntax tokens.
- Directory-mode ``source_path`` now silently ignores files whose name
starts with ``.`` (``.DS_Store``, editor swap files, ``.gitkeep``) and
skips unknown-extension files with a warning rather than crashing on
the first stray file.
- ``glob.glob(source_path, recursive=True)`` so ``**`` patterns walk
subdirectories (the docs already advertised this).
- Auto-extracted metadata (``file_name``, ``file_path``, ``row_index``,
``item_index``, ``page_number``) now takes precedence over
``metadata_fields`` with the same key (via ``setdefault``).
- Expanded ``template_fields`` to include ``file_type``,
``file_extensions``, ``parser`` so they can be driven from Jinja.
- Hoisted ``AirflowOptionalProviderFeatureException`` import to the
module top so the lazy ``pypdf`` / ``docx`` blocks are 2 lines each.
Docs
- Switched all inline ``code-block:: python`` snippets to
``exampleinclude::`` directives pointing at a new
``example_document_loader.py`` (basic, directory, bytes,
``json_text_field`` patterns), matching the convention every other
operator in this provider uses.
- New sections documenting encoding handling, metadata precedence, and
the directory-mode skip rules (files whose name starts with a ``.`` /
unknown-extension warn-and-skip).
Tests
- Dropped the tautological ``test_template_fields`` that just round-
tripped the class attribute; replaced with a behavioural check
confirming the templated fields are actually in the templated set.
- New coverage for: dot-prefixed-name skip, unknown-extension warn +
skip, ``encoding`` / ``encoding_errors``, ``json_text_field``, JSON
dict flatten, CSV empty-cell skip, ``metadata_fields`` precedence
(auto wins), recursive ``**`` glob.
- PDF/DOCX bytes tests assert the library was called with a
``BytesIO``, locking in the no-temp-file behaviour.
CSV files produce one document per row. JSON files with a top-level array
48
-
produce one document per element; a single JSON object produces one document.
43
+
CSV files produce one document per row, with empty cells skipped. JSON files
44
+
with a top-level array produce one document per element; a single JSON object
45
+
produces one document. By default each dict is flattened into ``"key: value,
46
+
key: value"`` text so the embedding sees content tokens rather than JSON
47
+
syntax (see the ``json_text_field`` section below for the structured variant).
49
48
50
49
PDF parsing
51
50
-----------
52
51
53
-
Install the ``pdf`` extra to parse PDF files via `pypdf <https://pypdf.readthedocs.io/>`__:
0 commit comments