Skip to content

Filesystem: A new reader still needs three edits, not one #302

Description

@hampsterx

About

GH-106 opened on this:

it would probably be worth centralizing the format-to-reader mapping so new readers can be
registered once

Format-name resolution is centralized now (GH-126, GH-160, GH-286): FORMAT_TO_READER is the one
table and reader_for_format the one lookup. Reader construction is not. Adding a format at
02a60bcb means editing three files:

  1. dlt_filesystem/source/format/readers.py, the reader function.
  2. dlt_filesystem/source/format/registry.py, the BASE_FILE_FORMATS or
    ITERABLE_FILE_FORMATS entry.
  3. dlt_filesystem/source/adapter.py, an import in the reader import block and a
    filesystem_resource | dlt.transformer(name="read_x", max_table_nesting=0)(read_x) line in
    the tuple readers() returns.

Step 3 restates by hand what FORMAT_TO_READER already knows, and the two have drifted:
read_csv_duckdb is imported, wired as a transformer and exposed on ReadersSource, but has no
FORMAT_TO_READER entry, so reader_for_format can never return it and no extension or
#format hint reaches it. It is reachable only through the Python readers() API, and nothing
tests or documents it.

The registry maps a format to a reader-function name, so the tuple can be built from it, which
would leave step 2 as the only registration.

Question

@amotl, worth building the transformer tuple from the registry, or is the explicit list
deliberate? It does keep every reader statically imported and greppable, which a generated tuple
gives up. And is read_csv_duckdb meant to be reachable by format hint, or is it Python-API only
on purpose?

Metadata

Metadata

Assignees

No one assigned

    Labels

    connectorAll about connectors: Bugs, improvements, pitches.needs discussionA topic that needs to mature on behalf of sensible discussions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions