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

source-postgres-batch: Paying down some technical debt #2406

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

willdonnelly
Copy link
Member

@willdonnelly willdonnelly commented Feb 14, 2025

Description:

This PR completely replaces the source-postgres-batch test suite with a new much more comprehensive version, and adds the necessary docker-compose / ci.yaml setup bits to actually run all of those tests in CI builds. This will hopefully let us make future source-postgres-batch changes with more confidence that we haven't broken anything important.

This PR also replaces DefaultQueryTemplate with a SelectQueryTemplate function to match what MySQL will have after its corresponding tech-debt PR is merged. The rationale for using a function here is that currently the Postgres connector only really works if you either:

  1. Use the default XMIN incremental syncs and don't mess with the cursor setting.
  2. Write your own query template to go with your selected cursor.

That's not great, ideally we would want to either not give users the option to use a cursor at all, or we'd want it to Just Work if you set a non-xmin cursor. And I would like to add support for discovering views in the near future, and views can't use XMIN for incremental syncs, so that means we should make things work as intended if the user doesn't specify their own query template but modifies the cursor.

Which means that we'll need to conditionally switch behavior and only use the xmin-incremental query when the cursor is ["xmin"]. And we could either implement that logic as part of an increasingly-horrible Go template, or we could just implement it in Go. I'm choosing the latter, but since this PR is supposed to have no user-visible functional impact this is just the preparatory refactoring.

Workflow steps:

No user-visible changes intended.


This change is Reviewable

This more or less completely replaces the source-postgres-batch
test suite, which previously...well, it existed. The new tests
should exercise much more of the connector's behavior, including
how it discovers and serializes all notable column types.
@willdonnelly willdonnelly requested a review from a team February 14, 2025 21:00
This modifies source-postgres-batch to use a function which takes
a resource as input and returns the query template to use, where
previously there was just a single constant template.

The reason for this is that in the near future it would be nice
to only use the XMIN incremental query if the cursor is ["xmin"]
and otherwise use a full-refresh or cursor-incremental query
instead, and since we're already omitting the default query from
discovered resources there is no reason to try and shoehorn all
of that intelligence into an overly complicated Go template.
@willdonnelly willdonnelly force-pushed the wgd/batch-postgres-tech-debt-20250214 branch from 6623764 to e931ede Compare February 14, 2025 21:01
As discussed in the comment, this is a workaround for a cause of
test snapshot instability. The fact that the workaround is needed
is itself indicative of a bug, but for now I just want tests to
demonstrate current behavior.
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.

1 participant