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 to automatically add deals_association_parent stream if it is mis… #16

Merged
merged 1 commit into from
Dec 6, 2023
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
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