-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
low-code connectors: fix parse and format methods #15326
Conversation
if self._datetime_format == "timestamp": | ||
return dt.timestamp() | ||
if self._datetime_format == TIMESTAMP_FORMAT: | ||
return int(dt.timestamp()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cast to int because dt.timestamp()
returns a flow
return datetime.datetime.fromtimestamp(int(date)).replace(tzinfo=self._timezone) | ||
return date | ||
elif isinstance(date, str): | ||
return datetime.datetime.strptime(str(date), self._datetime_format).replace(tzinfo=self._timezone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to use the specified datetime_format instead of relying on dateutil.parser's best guess
else: | ||
return dateutil.parser.parse(date).replace(tzinfo=self._timezone) | ||
elif isinstance(date, int): | ||
def parse_date(self, date: Union[str, datetime.datetime]) -> datetime.datetime: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't place the comment in the right spot so adding it here. Can you clarify in the doc string for datetime_format
what the reference for formats is? eg add a link to it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a link in the docstring and in MinMaxDatetime's https://github.com/airbytehq/airbyte/pull/15326/files#diff-3a6ff2f6eca71b4e166b1c8c852becb143ad4e079f5308967ff52828e747f035R34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the contract around datetime_format
is unclear -- can you clarify what are the expected/accepted values?
@sherifnada the contract is now stated in the docstring. I removed the "timestamp" magic keyword because "%s" is equivalent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
/publish-cdk dry-run=false
|
/publish-cdk dry-run=false
|
What
Fixes 2 bugs in the datetime stream slicer
self._datetime_format
How
_format_datetime
to an int if the format is "timestamp"strptime
andself._datetime_format
Recommended reading order
airbyte-cdk/python/airbyte_cdk/sources/declarative/stream_slicers/datetime_stream_slicer.py
airbyte-cdk/python/unit_tests/sources/declarative/stream_slicers/test_datetime_stream_slicer.py
🚨 User Impact 🚨
Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.
Pre-merge Checklist
Expand the relevant checklist and delete the others.
New Connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampledocs/integrations/README.md
airbyte-integrations/builds.md
Airbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereUpdating a connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampleAirbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereConnector Generator
-scaffold
in their name) have been updated with the latest scaffold by running./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates
then checking in your changesTests
Unit
Put your unit tests output here.
Integration
Put your integration tests output here.
Acceptance
Put your acceptance tests output here.