Skip to content

refactor: Parquet class accepts pre-loaded data instead of reading from disk #203

Description

@boscorat

Parent issue

#194 — function purification

Problem

Parquet.__init__ (parquet.py:49) reads an existing parquet file from disk during construction (line 56), and deletes the file if the column layout mismatches (line 60). This means you cannot create a Parquet instance without a real file on disk.

Similarly, Parquet.create() (line 70), Parquet.update() (line 77), and Parquet.delete() (line 83) all write to disk as their primary action.

Proposal

Accept an optional pre-loaded DataFrame in the constructor instead of reading from disk. Move file I/O to a @classmethod from_file(cls, path) factory. Return DataFrames from create/update/delete and let the caller handle writing.

Code relationships

Target class:

  • Parquetparquet.py:49

Subclasses (will inherit changes):

  • ChecksAndBalancesparquet.py
  • StatementHeadsparquet.py
  • StatementLinesparquet.py
  • BatchHeadsparquet.py
  • BatchLinesparquet.py

Callers (will need updating):

  • update_parquet()parquet.py:673
  • process_pdf_statement()statements.py:828 (creates BatchLines, StatementHeads, etc.)
  • update_db()database.py:387 (reads temp parquet files)

Existing tests

None. No direct tests exist for any Parquet class. Refactoring will not break any existing tests.

Siblings

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorcode refactoring

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions