Skip to content

Commit

Permalink
Fix to automatically add deals_association_parent stream if it is mis…
Browse files Browse the repository at this point in the history
…sing in the catalog (#16)
  • Loading branch information
xacadil authored and keyn4 committed Dec 16, 2023
1 parent 5991198 commit 78f9f23
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tap_hubspot_beta/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from singer_sdk.exceptions import FatalAPIError, RetriableAPIError
from singer_sdk.streams import RESTStream
from urllib3.exceptions import ProtocolError
from singer_sdk.mapper import SameRecordTransform, StreamMap
from singer_sdk.helpers._flattening import get_flattening_options

from pendulum import parse

Expand Down Expand Up @@ -262,6 +264,42 @@ def request_decorator(self, func):
on_backoff=self.backoff_handler,
)(func)
return decorator

@property
def stream_maps(self) -> List[StreamMap]:
"""Get stream transformation maps.
The 0th item is the primary stream map. List should not be empty.
Returns:
A list of one or more map transformations for this stream.
"""
if self._stream_maps:
return self._stream_maps

if self._tap.mapper:
#Append deals association stream if it is not in the catalog.
if self.name == "deals_association_parent" and self.name not in self._tap.mapper.stream_maps:
self._tap.mapper.stream_maps.update({"deals_association_parent":self._tap.mapper.stream_maps["deals"]})
self._tap.mapper.stream_maps["deals_association_parent"][0].stream_alias = "deals_association_parent"
self._stream_maps = self._tap.mapper.stream_maps[self.name]
self.logger.info(
f"Tap has custom mapper. Using {len(self.stream_maps)} provided map(s)."
)
else:
self.logger.info(
f"No custom mapper provided for '{self.name}'. "
"Using SameRecordTransform."
)
self._stream_maps = [
SameRecordTransform(
stream_alias=self.name,
raw_schema=self.schema,
key_properties=self.primary_keys,
flattening_options=get_flattening_options(self.config),
)
]
return self._stream_maps


class hubspotStreamSchema(hubspotStream):
Expand Down

0 comments on commit 78f9f23

Please sign in to comment.