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 microseconds timestamp format #373

Merged
merged 3 commits into from
Mar 3, 2025

Conversation

artem1205
Copy link
Contributor

@artem1205 artem1205 commented Feb 28, 2025

What

Resolving https://github.com/airbytehq/airbyte-internal-issues/issues/11530

Summary by CodeRabbit

  • New Features

    • Enhanced datetime formatting now offers a microsecond precision option for timestamps. Users can choose between second-level and more granular microsecond-level time displays.
  • Tests

    • Validation tests have been streamlined and updated to ensure accurate handling of both standard and enhanced timestamp formats, bolstering overall reliability.

Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
@artem1205 artem1205 self-assigned this Feb 28, 2025
@github-actions github-actions bot added the enhancement New feature or request label Feb 28, 2025
Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
@artem1205 artem1205 marked this pull request as ready for review February 28, 2025 21:30
Copy link
Contributor

coderabbitai bot commented Feb 28, 2025

📝 Walkthrough

Walkthrough

The changes introduce a new branch in the format_datetime function to handle the %ms format specifier. When %ms is provided, the function returns the datetime timestamp in microseconds by multiplying by 1,000,000. Additionally, the unit tests have been updated to remove the redundant test_name parameter and include test cases covering both the %s and %ms formats. No public API declarations have been altered.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/interpolation/macros.py Added a conditional branch in format_datetime to handle %ms by returning the timestamp in microseconds.
unit_tests/sources/declarative/interpolation/test_macros.py Simplified parameterization by removing the test_name parameter and updated test cases to verify both %s and %ms datetime formatting functionality.

Sequence Diagram(s)

sequenceDiagram
    participant C as Caller
    participant F as format_datetime
    C->>F: call format_datetime(dt, format)
    alt format == "%ms"
        F-->>C: return dt.timestamp() * 1,000,000 as string
    else format == "%s" or other
        F-->>C: return default formatted timestamp
    end
Loading

Would you like any further details or adjustments to the diagram?


📜 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 f4a404a and b0554f7.

📒 Files selected for processing (1)
  • unit_tests/sources/declarative/interpolation/test_macros.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • 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: Analyze (python)
🔇 Additional comments (7)
unit_tests/sources/declarative/interpolation/test_macros.py (7)

32-34: Nice simplification of the parametrize decorator!

Removing the redundant test_name parameter makes the test structure cleaner. This simplification focuses on the essential parameters that matter for the test cases.


74-85: Great additions for testing timestamp formats!

These new test cases properly validate both the existing seconds (%s) timestamp format and the new microseconds (%ms) format. The expected outputs look correct - 1640998861 seconds and 1640998861000000 microseconds for January 1, 2022, 01:01:01 UTC.


87-98: Well-labeled test ids for clarity

The updated test ids clearly describe what each test case is validating. The new ids for the timestamp formats are particularly descriptive.


101-101: Function signature improved

Removing the unused test_name parameter from the function signature aligns with the updated parameterization. This is a good cleanup.


106-115: Clean parameterization for duration tests

Similar cleanup as with the datetime tests - removing the redundant test_name parameter simplifies the test structure.


117-117: Type hints improve code quality!

Adding type hints to the function parameters makes the code more maintainable and helps with IDE support. Good addition!


101-145:

❓ Verification inconclusive

Verify compatibility with existing functionality

The tests look good! Do we need to add a test similar to the one on line 145 but for the microseconds format to ensure proper handling across different environments? Just a thought - wdyt?


🏁 Script executed:

#!/bin/bash
# Find if there is a similar test for microseconds format elsewhere
rg -A 2 "format_datetime.*%ms" --glob "!unit_tests/sources/declarative/interpolation/test_macros.py"

Length of output: 102


Clarification on microseconds format test coverage

The tests look solid overall! However, I didn't find any test covering microseconds formatting (for instance, using %ms) anywhere in the codebase. Would it be beneficial to add a dedicated test for this—similar to the UTC conversion test on line 145—to ensure consistent handling across different environments? wdyt?

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.

Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
@artem1205 artem1205 merged commit 61a9ee3 into main Mar 3, 2025
25 checks passed
@artem1205 artem1205 deleted the artem1205/add-microseconds-timestamp-format branch March 3, 2025 11:47
rpopov added a commit to rpopov/airbyte-python-cdk that referenced this pull request Mar 5, 2025
* main:
  fix: update cryptography package to latest version to address CVE (airbytehq#377)
  fix: (CDK) (HttpRequester) - Make the `HttpRequester.path` optional (airbytehq#370)
  feat: improved custom components handling (airbytehq#350)
  feat: add microseconds timestamp format (airbytehq#373)
  fix: Replace Unidecode with anyascii for permissive license (airbytehq#367)
  feat: add IncrementingCountCursor (airbytehq#346)
  feat: (low-code cdk)  datetime format with milliseconds (airbytehq#369)
  fix: (CDK) (AsyncRetriever) - Improve UX on variable naming and interpolation (airbytehq#368)
  fix: (CDK) (AsyncRetriever) - Add the `request` and `response` to each `async` operations (airbytehq#356)
  fix: (CDK) (ConnectorBuilder) - Add `auxiliary requests` to slice; support `TestRead` for AsyncRetriever (part 1/2) (airbytehq#355)
  feat(concurrent perpartition cursor): Add parent state updates (airbytehq#343)
  fix: update csv parser for builder compatibility (airbytehq#364)
  feat(low-code cdk): add interpolation for limit field in Rate (airbytehq#353)
  feat(low-code cdk): add AbstractStreamFacade processing as concurrent streams in declarative source (airbytehq#347)
  fix: (CDK) (CsvParser) - Fix the `\\` escaping when passing the `delimiter` from Builder's UI (airbytehq#358)
  feat: expose `str_to_datetime` jinja macro (airbytehq#351)
  fix: update CDK migration for 6.34.0 (airbytehq#348)
  feat: Removes `stream_state` interpolation from CDK (airbytehq#320)
  fix(declarative): Pass `extra_fields` in `global_substream_cursor` (airbytehq#195)
  feat(concurrent perpartition cursor): Refactor ConcurrentPerPartitionCursor (airbytehq#331)
  feat(HttpMocker): adding support for PUT requests and bytes responses (airbytehq#342)
  chore: use certified source for manifest-only test (airbytehq#338)
  feat: check for request_option mapping conflicts in individual components (airbytehq#328)
  feat(file-based): sync file acl permissions and identities (airbytehq#260)
  fix: (CDK) (Connector Builder) - refactor the `MessageGrouper` > `TestRead` (airbytehq#332)
  fix(low code): Fix missing cursor for ClientSideIncrementalRecordFilterDecorator (airbytehq#334)
  feat(low-code): Add API Budget (airbytehq#314)
  chore(decoder): clean decoders and make csvdecoder available (airbytehq#326)
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