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

feat: add formatting for epoch_microseconds #388

Merged
merged 4 commits into from
Mar 6, 2025

Conversation

artem1205
Copy link
Contributor

@artem1205 artem1205 commented Mar 6, 2025

What

Resolving airbytehq/airbyte#54151

How

add %epoch_microseconds to parser. Reason: concurrent curosor stateconverter uses parser to operate state values

Summary by CodeRabbit

  • New Features

    • Enhanced date handling by introducing a new timestamp format with microsecond-level precision for parsing and formatting dates.
  • Tests

    • Updated test cases to validate the new microsecond timestamp conversion, ensuring reliable and accurate date representation.
    • Streamlined test function signatures and added new scenarios for parsing and formatting datetime values.
    • Adjusted test parameters to align with the new microsecond format.

@artem1205 artem1205 self-assigned this Mar 6, 2025
Signed-off-by: Artem Inzhyyants <[email protected]>
@artem1205 artem1205 marked this pull request as ready for review March 6, 2025 10:50
Copy link
Contributor

coderabbitai bot commented Mar 6, 2025

📝 Walkthrough

Walkthrough

This update introduces support for a new datetime format (%epoch_microseconds) in the DatetimeParser class, enhancing both its parse and format methods. The format_datetime function in the macros has been adjusted to utilize this new format, and relevant unit tests have been updated to reflect these changes.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/datetime/datetime_parser.py Enhanced the parse and format methods of the DatetimeParser class to support the %epoch_microseconds format by adding corresponding logic for converting to and from microsecond timestamps.
airbyte_cdk/sources/declarative/interpolation/macros.py
unit_tests/sources/declarative/interpolation/test_macros.py
Modified the format_datetime function to replace the previous checks for %s and %ms with support for %epoch_microseconds, and updated the corresponding tests.
unit_tests/sources/declarative/datetime/test_datetime_parser.py Updated test function signatures and added new test cases for handling %epoch_microseconds format in both parsing and formatting functions.
airbyte_cdk/sources/declarative/datetime/__init__.py Removed MinMaxDatetime from the public API by deleting its import and entry in __all__.
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py
unit_tests/sources/declarative/extractors/test_record_filter.py
unit_tests/sources/declarative/parsers/test_model_to_component_factory.py
Updated import paths for MinMaxDatetime to reflect its new location in the min_max_datetime submodule.

Possibly related PRs

Suggested reviewers

  • maxi297
  • darynaishchenko
  • brianjlai

Would these suggestions work for you? wdyt?


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12b1200 and 0d2a4fe.

📒 Files selected for processing (5)
  • airbyte_cdk/sources/declarative/datetime/__init__.py (0 hunks)
  • airbyte_cdk/sources/declarative/interpolation/macros.py (2 hunks)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (1 hunks)
  • unit_tests/sources/declarative/extractors/test_record_filter.py (1 hunks)
  • unit_tests/sources/declarative/parsers/test_model_to_component_factory.py (1 hunks)
💤 Files with no reviewable changes (1)
  • airbyte_cdk/sources/declarative/datetime/init.py
✅ Files skipped from review due to trivial changes (3)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py
  • unit_tests/sources/declarative/parsers/test_model_to_component_factory.py
  • unit_tests/sources/declarative/extractors/test_record_filter.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • airbyte_cdk/sources/declarative/interpolation/macros.py
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: 'source-pokeapi' (skip=false)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Check: 'source-hardcoded-records' (skip=false)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Analyze (python)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
airbyte_cdk/sources/declarative/datetime/datetime_parser.py (1)

51-52: Format implementation for %epoch_microseconds looks good.

The implementation correctly converts a datetime to microseconds since the epoch. This aligns with the implementation in macros.py.

Since both "%ms" and "%epoch_microseconds" handle timestamps but at different granularities, it might be helpful to add a brief comment explaining their difference, wdyt?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8ec233 and 3a59755.

📒 Files selected for processing (3)
  • airbyte_cdk/sources/declarative/datetime/datetime_parser.py (2 hunks)
  • airbyte_cdk/sources/declarative/interpolation/macros.py (1 hunks)
  • unit_tests/sources/declarative/interpolation/test_macros.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
🔇 Additional comments (3)
airbyte_cdk/sources/declarative/interpolation/macros.py (1)

176-177: Implementation looks good!

The new format handling for "%epoch_microseconds" is correctly implemented, converting seconds to microseconds by multiplying by 1,000,000. This matches the implementation in the DatetimeParser class.

A tiny enhancement could be adding a brief comment before this branch to clarify its purpose (similar to the comment before the "%s" branch), wdyt?

unit_tests/sources/declarative/interpolation/test_macros.py (1)

82-82: Test update correctly verifies the new format.

The test case has been properly updated to use the new "%epoch_microseconds" format while keeping the same expected result, which makes sense since this is just renaming the format but keeping the same conversion logic.

airbyte_cdk/sources/declarative/datetime/datetime_parser.py (1)

32-33: Parse implementation for %epoch_microseconds looks good.

The implementation correctly adds microseconds to the UNIX epoch to parse a timestamp in microseconds. This is consistent with how other formats are handled.

@artem1205 artem1205 changed the title CDK: add formatting for epoch_microseconds feat: add formatting for epoch_microseconds Mar 6, 2025
Signed-off-by: Artem Inzhyyants <[email protected]>
@github-actions github-actions bot added the enhancement New feature or request label Mar 6, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
unit_tests/sources/declarative/datetime/test_datetime_parser.py (1)

12-127: Consider adding edge cases for microsecond parsing?

The changes look great! Would you consider adding a few edge cases for the microsecond timestamp parsing? For example, testing with very large or small values might help ensure robust handling of all possible inputs, wdyt?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a59755 and 12b1200.

📒 Files selected for processing (1)
  • unit_tests/sources/declarative/datetime/test_datetime_parser.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: 'source-pokeapi' (skip=false)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Check: 'source-hardcoded-records' (skip=false)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Analyze (python)
🔇 Additional comments (4)
unit_tests/sources/declarative/datetime/test_datetime_parser.py (4)

12-13: Looking good! Type annotations and improved test identifiers.

The parametrize decorator has been updated to remove the test_name parameter and add descriptive test IDs. The type annotations on the test function parameters also improve code readability. These changes will help with test clarity and maintainability.

Also applies to: 58-67, 69-69


38-41: Great addition of microseconds timestamp test case!

The test case for parsing timestamps in microseconds format is well implemented and aligns perfectly with the PR objective of adding support for %epoch_microseconds.


94-97: Nice complementary test for formatting to microseconds.

This test case properly verifies that formatting to microseconds works correctly, which complements the parsing test case added earlier. The expected output value is correct for the given input datetime.


75-76: Consistent improvements to format_datetime test structure.

The changes to the test_format_datetime function match the pattern applied to test_parse_date, with the removal of the test_name parameter, addition of descriptive IDs, and type annotations. This consistency across test functions is excellent!

Also applies to: 114-122, 124-124

Copy link
Contributor

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like there is a problem somewhere but I think it is in the formatting of epoch millis aka %ms. I'm kind of worried because it used in a couple connectors today (dixa, appcues, front, lever-hiring, linkedin-pages, mixmax...) and in most cases, it would mean that we send a epoch microsecond to the API instead and fixing that would be a breaking change

@artem1205 artem1205 requested a review from maxi297 March 6, 2025 17:01
Copy link
Contributor

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the improvement too

@artem1205 artem1205 merged commit 69ba54d into main Mar 6, 2025
25 checks passed
@artem1205 artem1205 deleted the artem1205/parse-format-epoch-microseconds branch March 6, 2025 18:49
rpopov added a commit to rpopov/airbyte-python-cdk that referenced this pull request Mar 6, 2025
* main:
  feat: add formatting for epoch_microseconds (airbytehq#388)
  feat(low-code cdk): remove unnecessary manifest print (airbytehq#390)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants