Skip to content

feat: Taps can now opt-in to emitting ACTIVATE_VERSION messages for streams with FULL_TABLE replication #2686

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

Merged
merged 16 commits into from
Jun 6, 2025

Conversation

edgarrmondragon
Copy link
Collaborator

@edgarrmondragon edgarrmondragon commented Sep 24, 2024

Related


📚 Documentation preview 📚: https://meltano-sdk--2686.org.readthedocs.build/en/2686/

Summary by Sourcery

Emit ACTIVATE_VERSION messages and attach version metadata for FULL_TABLE replication streams; adjust replication key behavior, batch messages, and sample mapper logic; and bolster snapshot-based tests for tap→mapper→target workflows.

New Features:

  • Enable taps to emit ACTIVATE_VERSION messages and include version metadata for streams using FULL_TABLE replication

Enhancements:

  • Use tap initialization time for replication key signposts in timestamp-based replication
  • Introduce a version field in RecordMessage and SDKBatchMessage to track table versions
  • Skip RemoveRecordTransform when mapping ActivateVersionMessage in sample mapper
  • Update codespell config to ignore JSONL snapshot files

Tests:

  • Add snapshot-driven end-to-end tests for tap→mapper→target flows with time-machine for deterministic timestamps
  • Expand and update sample and core test suites with new fixtures and snapshot files

Summary by Sourcery

Enable taps to optionally emit ACTIVATE_VERSION messages and include version metadata for FULL_TABLE replication streams, extend core stream and message classes to support version tracking, update sample mapper and capabilities, and add snapshot-driven tests for tap→mapper→target workflows.

New Features:

  • Add opt-in support for emitting ACTIVATE_VERSION messages with version metadata for FULL_TABLE replication streams.

Enhancements:

  • Add a version field to RecordMessage and SDKBatchMessage to track table version.
  • Use tap initialization timestamp as the replication key signpost for timestamp-based replication.
  • Introduce emit_activate_version_messages config property and update tap capabilities to include ACTIVATE_VERSION.
  • Skip RemoveRecordTransform when mapping ActivateVersionMessage in the sample mapper.
  • Update codespell configuration to ignore JSONL snapshot files.

Tests:

  • Add snapshot-driven end-to-end tests for CSV and SQLite targets covering activate_version, hard delete, and missing properties scenarios.
  • Refactor tests to use pytest snapshots, caplog, time_machine fixture, and deterministic table names using request.node.name.

Chores:

  • Adjust existing test setup to use pytest snapshot plugin and remove UUID-based table naming.

Copy link

codspeed-hq bot commented Sep 24, 2024

CodSpeed Performance Report

Merging #2686 will not alter performance

Comparing edgarrmondragon/feat/activate_version (1acde43) with main (9497d9b)

Summary

✅ 8 untouched benchmarks

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.13%. Comparing base (9497d9b) to head (1acde43).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2686      +/-   ##
==========================================
+ Coverage   92.01%   92.13%   +0.11%     
==========================================
  Files          62       62              
  Lines        5298     5312      +14     
  Branches      682      683       +1     
==========================================
+ Hits         4875     4894      +19     
+ Misses        297      293       -4     
+ Partials      126      125       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@edgarrmondragon edgarrmondragon self-assigned this Oct 15, 2024
@edgarrmondragon edgarrmondragon force-pushed the edgarrmondragon/feat/activate_version branch from fe4d249 to 722567c Compare May 21, 2025 20:37
@edgarrmondragon edgarrmondragon force-pushed the edgarrmondragon/feat/activate_version branch from 722567c to 87cff00 Compare May 21, 2025 20:40
@edgarrmondragon
Copy link
Collaborator Author

@sourcery-ai review

Copy link
Contributor

sourcery-ai bot commented Jun 3, 2025

Reviewer's Guide

This PR adds an optional ACTIVATE_VERSION message emission flow for full‐table taps with version metadata, refines replication key timing, updates sample mapper logic, and bolsters snapshot‐driven end‐to‐end tests across CSV and SQLite targets.

File-Level Changes

Change Details Files
Configurable emission of ACTIVATE_VERSION messages in taps
  • Introduce emit_activate_version_messages config property and capability flag
  • Expose emit_activate_version_messages property on streams
  • Set _stream_version from tap initialization time and write activate messages in sync
  • Add _write_activate_version_message helper in core stream logic
singer_sdk/streams/core.py
singer_sdk/helpers/capabilities.py
singer_sdk/tap_base.py
Attach version metadata to record and batch messages
  • Include version on RecordMessage output
  • Add version field to SDKBatchMessage for full table batches
singer_sdk/streams/core.py
singer_sdk/helpers/_batch.py
Use tap initialization time for replication key signpost
  • Return initialized_at timestamp for timestamp‐based replication key signpost
singer_sdk/streams/core.py
Skip removal transform when mapping activate version messages
  • Bypass RemoveRecordTransform in map_activate_version_message
samples/sample_mapper/mapper.py
Enhance snapshot‐driven end‐to‐end tests for CSV and SQLite
  • Parametrize CSV mapper/target tests to cover both emit and no‐emit flows
  • Add pytest.mark.snapshot, caplog assertions, and use request.node.name for table names in SQLite tests
  • Update snapshot directories and files for new activate version and log outputs
tests/samples/test_target_csv.py
tests/samples/test_target_sqlite.py
tests/core/test_parent_child.py
tests/samples/snapshots/**

Assessment against linked issues

Issue Objective Addressed Explanation

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @edgarrmondragon - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 2 issues found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

def test_countries_to_csv_mapped(csv_config: dict):
@time_machine.travel(DATETIME, tick=False)
@pytest.mark.snapshot
def test_countries_to_csv_mapped(
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Consider testing behavior for non-FULL_TABLE replication streams.

Add a test with a non-FULL_TABLE replication method (e.g., INCREMENTAL) to confirm that ACTIVATE_VERSION messages are not emitted and RECORD messages lack the new stream version field.

@edgarrmondragon edgarrmondragon modified the milestones: v1.0 Release, v0.47 Jun 3, 2025
@edgarrmondragon edgarrmondragon force-pushed the edgarrmondragon/feat/activate_version branch from 3e0ceb3 to 18de4a8 Compare June 3, 2025 23:15
@edgarrmondragon edgarrmondragon added this pull request to the merge queue Jun 6, 2025
Merged via the queue into main with commit 0373c6e Jun 6, 2025
36 checks passed
@edgarrmondragon edgarrmondragon deleted the edgarrmondragon/feat/activate_version branch June 6, 2025 17:54
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @edgarrmondragon - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for ACTIVATE_VERSION message types
1 participant