From 998083aa3178d8062f7bcb5d089107a8fd41475b Mon Sep 17 00:00:00 2001 From: Greg Koutsimpogiorgos <38937533+gregkoutsimp@users.noreply.github.com> Date: Wed, 11 Sep 2024 20:55:14 +0200 Subject: [PATCH] fix: Mapped datetime values are now typed as `date-time` strings in the schema message (#2665) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * check for date and datetime in stream_maps * expr.endswith(".date()") * Update mapper.py --------- Co-authored-by: Greg Koutsimpogiorgos Co-authored-by: Edgar Ramírez Mondragón <16805946+edgarrmondragon@users.noreply.github.com> --- singer_sdk/mapper.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/singer_sdk/mapper.py b/singer_sdk/mapper.py index a0de52e01..c222acc67 100644 --- a/singer_sdk/mapper.py +++ b/singer_sdk/mapper.py @@ -359,7 +359,7 @@ def _eval( return result - def _eval_type( + def _eval_type( # noqa: PLR0911 self, expr: str, default: th.JSONTypeHelper | None = None, @@ -398,6 +398,12 @@ def _eval_type( if expr.startswith("bool("): return th.BooleanType() + if expr.startswith("datetime.date") or expr.endswith(".date()"): + return th.DateType() + + if expr.startswith("datetime.datetime"): + return th.DateTimeType() + return th.StringType() if expr[0] == "'" and expr[-1] == "'" else default def _init_functions_and_schema( # noqa: PLR0912, PLR0915, C901