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

fix(ingestion/kafka-connect): update retrieval of database name in Debezium SQL Server #8608

Conversation

Starkie
Copy link
Contributor

@Starkie Starkie commented Aug 10, 2023

In the version 2.0 of the Debezium SQL Server connector the name of the property database.dbname changed to database.names. I've checked the other supported connectors and it seems this is the only one affected.

In this PR I've changed the default property to retrieve from the connector's manifest to database.names and left the database.dbname as a fallback.

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

@github-actions github-actions bot added the ingestion PR or Issue related to the ingestion of metadata label Aug 10, 2023
@@ -686,7 +686,7 @@ def get_parser(
parser = self.DebeziumParser(
source_platform="mssql",
server_name=self.get_server_name(connector_manifest),
database_name=connector_manifest.config.get("database.dbname"),
database_name=connector_manifest.config.get("database.names") or connector_manifest.config.get("database.dbname"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this will work only if database.names has single database name, whereas database.names supports specifying multiple comma separated database names. Is that correct understanding ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that you mention it, I think that's right. In that specific case, you wouldn't be able to discern to which database the table belongs to with the information available in the manifest. If you picked only one of them, it could lead to erroneous lineage relationships.

Since the property database.dbname isn't available anymore for the SQL Server connector, could we support the single DB use case? If more than one DBs are detected, maybe a warning could be shown and the parameter database_name could be left empty.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, can do that. One small change suggested - when more than one DBs are detected, raise an exception, it'll get caught in the outer try..except block where we initialize DebeziumSourceConnectorLineages per connector. This will automatically report a warning . If we leave database_name empty, it'll generate incorrect table urns, without database name.

That being said, what do you think, should be ideal behavior if multiple database names are specified in connector ? What are the resolved topics in case multiple database.names (db1,db2) are specified, and both of databases have same schema name(schema1) and same table name(table1) inside it. Are changes to both tables (db1.schema1.table1 and db2.schema1.table1) written to same kafka topic or different ones ?

Copy link
Contributor Author

@Starkie Starkie Aug 21, 2023

Choose a reason for hiding this comment

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

Mmmh... I'm not sure, I haven't encountered that use case yet. Reading the docs it seems they'd be written to the same topic. Maybe the connector expects the table to exist in boths DBs and follow the same naming schemas.

How should that be translated on the lineage? Should we split the DBs and create a new lineage for each combination with the tables?

For the moment, could we finish this fix and setup a new PR with the proper scope?

Copy link
Collaborator

Choose a reason for hiding this comment

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

that makes sense to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahh, my bad, the try..except is not present in parsing block of DebeziumSourceConnector._extract_lineages but only present in ConfluentS3SinkConnector._extract_lineages

Could you please add this try..except in DebeziumSourceConnector and then I can approve the PR.

Copy link
Contributor Author

@Starkie Starkie Aug 22, 2023

Choose a reason for hiding this comment

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

Sure thing! Just pushed the changes.

There's also some fixes requested by the linters, like casting database_name to str when checking if there's more than one DB.

@mayurinehate mayurinehate added the community-contribution PR or Issue raised by member(s) of DataHub Community label Aug 14, 2023
@mayurinehate mayurinehate added the pending-submitter-response Issue/request has been reviewed but requires a response from the submitter label Aug 18, 2023
@Starkie Starkie force-pushed the fix/ingestion/kafka_connect-sqlserver-debezium-property branch from fd91a2c to 5d09068 Compare August 21, 2023 07:58
Copy link
Collaborator

@mayurinehate mayurinehate left a comment

Choose a reason for hiding this comment

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

lgtm

@mayurinehate mayurinehate removed the pending-submitter-response Issue/request has been reviewed but requires a response from the submitter label Aug 23, 2023
@asikowitz asikowitz added the merge-pending-ci A PR that has passed review and should be merged once CI is green. label Aug 23, 2023
@anshbansal anshbansal merged commit d6a935e into datahub-project:master Aug 24, 2023
48 of 49 checks passed
@anshbansal
Copy link
Collaborator

unrelated failure so merging this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution PR or Issue raised by member(s) of DataHub Community ingestion PR or Issue related to the ingestion of metadata merge-pending-ci A PR that has passed review and should be merged once CI is green.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants