Skip to content

Commit

Permalink
fix: Mapped datetime values are now typed as date-time strings in t…
Browse files Browse the repository at this point in the history
…he schema message (#2665)

* check for date and datetime in stream_maps

* expr.endswith(".date()")

* Update mapper.py

---------

Co-authored-by: Greg Koutsimpogiorgos <[email protected]>
Co-authored-by: Edgar Ramírez Mondragón <[email protected]>
  • Loading branch information
3 people committed Sep 11, 2024
1 parent 6b3869d commit 998083a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion singer_sdk/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def _eval(

return result

def _eval_type(
def _eval_type( # noqa: PLR0911
self,
expr: str,
default: th.JSONTypeHelper | None = None,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 998083a

Please sign in to comment.