Andy Carter
07/06/2023, 2:15 PMselect:
config to change what gets passed to my tap's rest API call? For mailchimp, you can choose to exclude certain variables which means a quicker api response. If those are excluded in select:
, I will change the api call.
More info below:Andy Carter
07/06/2023, 2:30 PM{
"api_key": "...",
"start_date": "2001-04-01",
"dc": "...",
"select": [
"*.*",
"!*.ip",
"!*.location",
"!*.merge_fields"
]
}
But if I check self.metadata
for the field in question:
<tap_mailchimp.streams.ListsMembersStream object at 0x7fc64857f700>
self.metadata[('properties', 'merge_fields')]
Metadata(inclusion=<InclusionType.AVAILABLE: 'available'>, selected=None, selected_by_default=None)
it looks like it hasn't been excluded. Does the metadata only apply when sent to a target?edgar_ramirez_mondragon
07/06/2023, 4:14 PMselect
is a Meltano feature that works as a nice interface to the singer catalog, so outside of Meltano taps don't usually handle a direct select
input but instead expect selection to be handled by passing --catalog
.
The stream class has a mask
property that you can use to check if a field is selected, via the passed catalog.edgar_ramirez_mondragon
07/06/2023, 4:17 PMdef get_url_params(
self,
context: dict | None, # noqa: ARG002
next_page_token: int,
) -> dict[str, t.Any]:
"""Get URL query parameters for Mailchimp streams."""
<http://self.logger.info|self.logger.info>("Page offset %s", next_page_token)
fields = self.selected_fields
<http://self.logger.info|self.logger.info>("Fields %s", fields)
return {
"count": self._page_size,
"offset": next_page_token,
"fields": fields,
}
@property
def selected_fields(self) -> list[str]:
"""Get selected fields from the input catalog.
Returns:
List of selected fields, with nested properties delimited by a dot.
"""
if self._tap_input_catalog:
return [
".".join(breadcrumb[1::2])
for breadcrumb, selected in self.mask.items()
if selected
]
return []
Andy Carter
07/06/2023, 9:55 PMselect:
in my config.json like aboveedgar_ramirez_mondragon
07/06/2023, 10:00 PMselect
can't be used in config.json. There's an issue suggesting we port that behavior from Meltano: https://github.com/meltano/sdk/issues/1383