From 037b2cf76c836551ac09d87abb0523b972bdbe74 Mon Sep 17 00:00:00 2001 From: "Roman Yermilov [GL]" <86300758+roman-yermilov-gl@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:24:39 +0400 Subject: [PATCH] Source Amplitude: fix data region keyerror (#30525) --- airbyte-integrations/connectors/source-amplitude/Dockerfile | 2 +- .../connectors/source-amplitude/metadata.yaml | 2 +- .../connectors/source-amplitude/source_amplitude/source.py | 2 +- .../connectors/source-amplitude/source_amplitude/streams.py | 5 +++++ docs/integrations/sources/amplitude.md | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/airbyte-integrations/connectors/source-amplitude/Dockerfile b/airbyte-integrations/connectors/source-amplitude/Dockerfile index a965120d2ed2..728f59891126 100644 --- a/airbyte-integrations/connectors/source-amplitude/Dockerfile +++ b/airbyte-integrations/connectors/source-amplitude/Dockerfile @@ -34,5 +34,5 @@ COPY source_amplitude ./source_amplitude ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] -LABEL io.airbyte.version=0.3.1 +LABEL io.airbyte.version=0.3.2 LABEL io.airbyte.name=airbyte/source-amplitude diff --git a/airbyte-integrations/connectors/source-amplitude/metadata.yaml b/airbyte-integrations/connectors/source-amplitude/metadata.yaml index aa4d13a9ecb9..5928851f0ccb 100644 --- a/airbyte-integrations/connectors/source-amplitude/metadata.yaml +++ b/airbyte-integrations/connectors/source-amplitude/metadata.yaml @@ -6,7 +6,7 @@ data: connectorSubtype: api connectorType: source definitionId: fa9f58c6-2d03-4237-aaa4-07d75e0c1396 - dockerImageTag: 0.3.1 + dockerImageTag: 0.3.2 dockerRepository: airbyte/source-amplitude githubIssueLabel: source-amplitude icon: amplitude.svg diff --git a/airbyte-integrations/connectors/source-amplitude/source_amplitude/source.py b/airbyte-integrations/connectors/source-amplitude/source_amplitude/source.py index 247482de5163..6ff2160da69c 100644 --- a/airbyte-integrations/connectors/source-amplitude/source_amplitude/source.py +++ b/airbyte-integrations/connectors/source-amplitude/source_amplitude/source.py @@ -36,7 +36,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]: Events( authenticator=auth, start_date=config["start_date"], - data_region=config["data_region"], + data_region=config.get("data_region", "Standard Server"), event_time_interval={"size_unit": "hours", "size": config.get("request_time_range", 24)}, ) ) diff --git a/airbyte-integrations/connectors/source-amplitude/source_amplitude/streams.py b/airbyte-integrations/connectors/source-amplitude/source_amplitude/streams.py index 2a9150e9f86a..20ae757e0241 100644 --- a/airbyte-integrations/connectors/source-amplitude/source_amplitude/streams.py +++ b/airbyte-integrations/connectors/source-amplitude/source_amplitude/streams.py @@ -101,6 +101,11 @@ def _date_time_to_rfc3339(self, record: MutableMapping[str, Any]) -> MutableMapp return record def get_most_recent_cursor(self, stream_state: Mapping[str, Any] = None) -> datetime.datetime: + """ + Use `start_time` instead of `cursor` in the case of more recent. + This can happen whenever a user simply finds that they are syncing to much data and would like to change `start_time` to be more recent. + See: https://github.com/airbytehq/airbyte/issues/25367 for more details + """ cursor_date = ( pendulum.parse(stream_state[self.cursor_field]) if stream_state and self.cursor_field in stream_state diff --git a/docs/integrations/sources/amplitude.md b/docs/integrations/sources/amplitude.md index 43e851439fd0..1d1cb424902d 100644 --- a/docs/integrations/sources/amplitude.md +++ b/docs/integrations/sources/amplitude.md @@ -43,6 +43,7 @@ The Amplitude connector ideally should gracefully handle Amplitude API limitatio | Version | Date | Pull Request | Subject | |:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------------------------| +| 0.3.2 | 2023-09-18 | [30525](https://github.com/airbytehq/airbyte/pull/30525) | Fix `KeyError` while getting `data_region` from config | | 0.3.1 | 2023-09-15 | [30471](https://github.com/airbytehq/airbyte/pull/30471) | Fix `Event` stream: Use `start_time` instead of cursor in the case of more recent | | 0.3.0 | 2023-09-13 | [30378](https://github.com/airbytehq/airbyte/pull/30378) | Switch to latest CDK version | | 0.2.4 | 2023-05-05 | [25842](https://github.com/airbytehq/airbyte/pull/25842) | added missing attrs in events schema, enabled default availability strategy |