Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cast all custom report fields to strings #68

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading