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-mysql-batch: Paying down some technical debt #2400

Merged
merged 5 commits into from
Feb 18, 2025

Conversation

willdonnelly
Copy link
Member

@willdonnelly willdonnelly commented Feb 14, 2025

Description:

This PR takes the source-mysql-batch test suite from "hilariously poorly tested" to "probably a bit over-tested" with about 700 lines of new test code covering all the important MySQL column types as well as various edge cases of key/cursor handling.

This PR also adds table and schema properties to the resource config struct and implements the same logic that source-postgres-batch has had for some time where if a query template is specified in the resource config we use it, but otherwise the connector knows what default query to use and plugs in the table/schema name from the resource into that hard-coded default, and when discovering new tables we always leave the template override blank.

I intend to do both of these things for the other batch SQL capture connectors in the near future, because I would really like to be able to make changes to them all with more confidence.

Workflow steps:

Nothing should change for existing users. New users will no longer have a big ugly template to look at if they inspect the discovered resource bindings, but they still have the option of writing their own if they really want to.

Notes:

If you look closely at the datatype test snapshots you might notice that our serialization of some column types is...less than optimal. We might want to consider improving that soon, but right now my goal was just to document via snapshots the current connector behavior so we can at least tell if a future change impacts anything.


This change is Reviewable

@willdonnelly willdonnelly requested a review from a team February 14, 2025 00:41
@willdonnelly willdonnelly added the change:unplanned Unplanned change, useful for things like doc updates label Feb 14, 2025
@willdonnelly willdonnelly force-pushed the wgd/batch-mysql-default-template-20250212 branch from 01ffa90 to d78da40 Compare February 14, 2025 00:50
Copy link
Member

@williamhbaker williamhbaker left a comment

Choose a reason for hiding this comment

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

LGTM

This modifies source-mysql-batch to behave similarly to how
source-postgres-batch handles query templates and generated
resource specs -- instead of hard-coding a complicated and
ugly query template by default, we instead just put the
table name and schema in the resource spec and say that if
the template field is blank we apply a default query template
which knows how to plug in the table name and schema.

This is pretty much just a tech debt reduction thing, there
are good reasons we did it this way for Postgres and it's good
to have all the batch SQL captures be roughly similar in how
they behave.
Getting ready to start implementing a bunch of tests.
It's well past time that we ought to have proper test coverage of
datatype support in the MySQL Batch capture connector. This commit
adds tests which exercise almost all MySQL column types.
Adds more test scenarios, including:

- A full-refresh table with no cursor.
- A polling interval which yields no results.
- Modifications and deletions as well as inserts.
- Null values in the cursor column.
- A two-column compound cursor.
- An explicit query template and no table/schema names, like
  what all preexisting captures in production have.
@willdonnelly willdonnelly force-pushed the wgd/batch-mysql-default-template-20250212 branch from c797247 to bd0f76d Compare February 14, 2025 21:01
@willdonnelly willdonnelly merged commit 773b66b into main Feb 18, 2025
48 of 55 checks passed
@willdonnelly willdonnelly deleted the wgd/batch-mysql-default-template-20250212 branch February 18, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:unplanned Unplanned change, useful for things like doc updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants