Skip to content

Meta data additon forced replcation key#49

Open
romilqlik wants to merge 10 commits intomasterfrom
metadata
Open

Meta data additon forced replcation key#49
romilqlik wants to merge 10 commits intomasterfrom
metadata

Conversation

@romilqlik
Copy link
Copy Markdown

@romilqlik romilqlik commented Oct 3, 2025

Description of change

What changed

  • Added forced-replication-method metadata to all discovered streams in tap_eloqua/discover.py
    • Streams with an UpdatedAt (or updatedAt) property are set to INCREMENTAL
    • All other streams are set to FULL_TABLE
  • Renamed local metadata variable to md_list to resolve naming conflict with the imported singer.metadata module (aliased as mdata)
  • Bumped Python version from 3.9 to 3.12 in CircleCI config
  • Bumped dependencies: backoff==2.2.1, requests==2.33.1, pendulum==3.2.0, singer-python==6.8.0

Tests added

Unit tests (tests/unittests/):
Integration tests (tests/):

CI changes (.circleci/config.yml)

  • Added Pylint step (pylint tap_eloqua --disable=C,R,W) — enforces zero error/warning-level lint issues
  • Added Unit Tests step — runs tests/unittests/ in isolation using the tap's own virtualenv
  • Separated Integration Tests step to use the tap-tester virtualenv (required for Stitch test framework)

Manual QA steps

  • Run python -m unittest discover -s tests/unittests -p 'test_*.py' and confirm all unit tests pass
  • Run discovery and confirm output catalog contains forced-replication-method in root metadata for each stream
  • Confirm INCREMENTAL streams (e.g. accounts, contacts, campaigns) have UpdatedAt/updatedAt in their schema
  • Confirm FULL_TABLE streams (e.g. visitors, activity streams) do not

Risks

  • Changing forced-replication-method metadata is a catalog-level change; downstream targets or orchestrators that read this field may change sync behavior on next run
  • Schema tightening (adding explicit replication method) may require a catalog reset for existing connections

Rollback steps

  • Revert this branch
  • Existing connections may need to re-run discovery to restore previous catalog state

Rollback steps

  • revert this branch

AI generated code

https://internal.qlik.dev/general/ways-of-working/code-reviews/#guidelines-for-ai-generated-code

  • this PR has been written with the help of GitHub Copilot or another generative AI tool

Comment thread tap_eloqua/discover.py Outdated
Comment thread tap_eloqua/discover.py Outdated
Comment thread tap_eloqua/discover.py
metadata = field_metadata[stream_name]

# existing field-level metadata from schema.py
md_list = field_metadata[stream_name]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What was the need to change the variable name from metadata to md_list?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@RushiT0122

Renamed the local metadata variable to md_list because it conflicted with the Singer metadata module.
To avoid this naming clash, the Singer module is now aliased as mdata, ensuring all metadata operations (write, to_map, etc.) behave correctly.

Also added the required top-level metadata fields — inclusion and forced-replication-method — to align with Singer catalog specifications and client expectations.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This needs unit test.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We don't have any test cases from the beginning for this tap. we have incorporate unittest. is there any reference. for this kind of scenario.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Added test cases. for this change. please check

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds forced replication method metadata to Eloqua tap streams, automatically setting INCREMENTAL for streams with an UpdatedAt property and FULL_TABLE otherwise.

Key Changes:

  • Modified the discover function to detect UpdatedAt properties and set appropriate forced-replication-method metadata
  • Added comprehensive test coverage to verify the metadata is correctly applied to all discovered streams

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tap_eloqua/discover.py Adds logic to detect UpdatedAt property and write forced-replication-method metadata to stream catalog entries
test/test_discovery_metadata.py Adds unit test verifying that forced-replication-method metadata is correctly set based on schema properties

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tap_eloqua/discover.py Outdated
schema = Schema.from_dict(schema_dict)
metadata = field_metadata[stream_name]
properties = schema_dict.get("properties", {})
replication_key = "updatedAt" if "UpdatedAt" in properties else None
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

The replication_key is set to lowercase 'updatedAt' but the check is for 'UpdatedAt' with capital letters. This inconsistency could cause issues if the replication_key value is used elsewhere in the codebase expecting the correct casing.

Suggested change
replication_key = "updatedAt" if "UpdatedAt" in properties else None
replication_key = "UpdatedAt" if "UpdatedAt" in properties else None

Copilot uses AI. Check for mistakes.
Comment thread test/test_discovery_metadata.py Outdated
Comment on lines +17 to +23
# compute expected replication method from schema properties
schema_props = s.schema.to_dict().get("properties", {})
expected_rep_method = "INCREMENTAL" if "UpdatedAt" in schema_props else "FULL_TABLE"

self.assertEqual(root.get("forced-replication-method"),
expected_rep_method,
msg=f"forced-replication-method mismatch for stream {s.stream}")
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

The test duplicates the logic from the discover function (checking for 'UpdatedAt' property). Consider testing against known stream fixtures with expected outcomes rather than replicating the implementation logic, which makes the test less effective at catching bugs.

Suggested change
# compute expected replication method from schema properties
schema_props = s.schema.to_dict().get("properties", {})
expected_rep_method = "INCREMENTAL" if "UpdatedAt" in schema_props else "FULL_TABLE"
self.assertEqual(root.get("forced-replication-method"),
expected_rep_method,
msg=f"forced-replication-method mismatch for stream {s.stream}")
# Use known expected replication methods for each stream
expected_rep_methods = {
"Contacts": "INCREMENTAL",
"Accounts": "FULL_TABLE",
"Activities": "INCREMENTAL",
# Add other streams and their expected replication methods here
}
stream_name = s.stream
self.assertIn(stream_name, expected_rep_methods, msg=f"Unknown stream {stream_name} in test fixture")
expected_rep_method = expected_rep_methods[stream_name]
self.assertEqual(root.get("forced-replication-method"),
expected_rep_method,
msg=f"forced-replication-method mismatch for stream {stream_name}")

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This comment is consider. and made the changes. @RushiT0122

@RushiT0122 RushiT0122 requested a review from Copilot November 28, 2025 14:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tap_eloqua/discover.py Outdated
schema = Schema.from_dict(schema_dict)
metadata = field_metadata[stream_name]
properties = schema_dict.get("properties", {})
replication_key = next((k for k in properties if k.lower() == "updatedat"), None)
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

The case-insensitive comparison k.lower() == 'updatedat' will fail if the property key is 'updatedAt' (camelCase). This logic assumes all property keys are lowercase, but the comparison converts them to lowercase for matching. Consider verifying that property keys in the schema are actually lowercase, or adjust the logic to handle camelCase properly (e.g., comparing against both 'updatedat' and 'updatedAt').

Suggested change
replication_key = next((k for k in properties if k.lower() == "updatedat"), None)
# Accept both "updatedAt" (camelCase) and "updatedat" (lowercase) as replication keys
replication_key = next(
(k for k in properties if k.lower() == "updatedat" or k == "updatedAt"),
None
)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this comment is valid but you should explain inconsistency in the replication name and why this is handled like in the comment.

I will not hold the PR for this but please add the appropriate comment before merging.

Comment thread tap_eloqua/discover.py Outdated
Comment thread tests/test_discovery_metadata.py
Pagadala Narender and others added 2 commits December 1, 2025 08:00
* upgrade python and added unittests

* Update tests/test_sync.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/test_sync.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* review comments

* resolve review comments

* remove out of scope changes

* request lib to latest

* fix review comments

* resolve review comments

* resolve review comments

* updated changelog

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ranit Saha <ranit.saha@globallogic.com>
Comment thread CHANGELOG.md

## [1.4.0] 2026-04-08
- Added replication method into metadata [#49](https://github.com/singer-io/tap-eloqua/pull/49)
- Bump backoff, requests, pendulum, singer-python version [#50](https://github.com/singer-io/tap-eloqua/pull/50)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

also update for adding unittests and integration tests

Comment thread .circleci/config.yml
command: |
source /usr/local/share/virtualenvs/tap-tester/bin/activate
stitch-validate-json /usr/local/share/virtualenvs/tap-eloqua/lib/python3.9/site-packages/tap_eloqua/schemas/*.json
stitch-validate-json /usr/local/share/virtualenvs/tap-eloqua/lib/python3.12/site-packages/tap_eloqua/schemas/*.json
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

please also add pylint, unittest test validation in config file.

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.

8 participants