Skip to content

Commit

Permalink
cast all custom report fields to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
pnadolny13 committed Dec 6, 2024
1 parent 60974ca commit 95f217e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tap_service_titan/streams/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,17 @@ def _get_initial_date_param(self) -> date | None:

@staticmethod
def _get_datatype(string_type: str) -> th.JSONTypeHelper:
mapping = {
# String , Number , Boolean , Date , Time
"String": th.StringType(),
"Number": th.NumberType(),
"Boolean": th.BooleanType(),
"Date": th.DateTimeType(),
"Time": th.StringType(),
}
return mapping.get(string_type, th.StringType())
# TODO: Use proper types once the API is fixed https://github.com/archdotdev/tap-service-titan/issues/67
return th.StringType()
# mapping = {
# # String , Number , Boolean , Date , Time
# "String": th.StringType(),
# "Number": th.NumberType(),
# "Boolean": th.BooleanType(),
# "Date": th.DateTimeType(),
# "Time": th.StringType(),
# }
# return mapping.get(string_type, th.StringType())

def _get_report_metadata(self) -> dict:
report_category = self._report["report_category"]
Expand Down Expand Up @@ -196,7 +198,9 @@ def parse_response(self, response: requests.Response) -> t.Iterable[dict]:
resp = response.json()
field_names = [field["name"] for field in resp["fields"]]
for record in resp["data"]:
data = dict(zip(field_names, record))
# TODO: Use proper types once the API is fixed https://github.com/archdotdev/tap-service-titan/issues/67
string_record = [str(val) if val is not None else "" for val in record]
data = dict(zip(field_names, string_record))
# Add the backfill date to the record if configured
if "backfill_date_parameter" in self._report:
data[self._report["backfill_date_parameter"]] = (
Expand Down

0 comments on commit 95f217e

Please sign in to comment.