diff --git a/pyproject.toml b/pyproject.toml index 5aed6b9..fdadda8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tap-csv" -version = "1.1.0" +version = "1.2.0" description = "Singer tap for CSV, built with the Meltano SDK for Singer Taps." authors = ["Pat Nadolny"] keywords = [ diff --git a/tap_csv/client.py b/tap_csv/client.py index cae3892..f4b3739 100644 --- a/tap_csv/client.py +++ b/tap_csv/client.py @@ -6,6 +6,7 @@ import os import typing as t from datetime import datetime, timezone +from functools import cached_property from singer_sdk import typing as th from singer_sdk.streams import Stream @@ -121,12 +122,14 @@ def get_rows(self, file_path: str) -> t.Iterable[list]: with open(file_path, encoding=encoding) as f: yield from csv.reader(f, dialect="tap_dialect") - @property + @cached_property def schema(self) -> dict: """Return dictionary of record schema. Dynamically detect the json schema for the stream. - This is evaluated prior to any records being retrieved. + + This property is accessed multiple times for each record + so it's important to cache the result. """ properties: list[th.Property] = [] self.primary_keys = self.file_config.get("keys", [])