Skip to content

refactor(ingest): extract shared JDBC URL parsing into common/jdbc - #20894

Merged
acrylJonny merged 5 commits into
masterfrom
boomi/00-jdbc
Dec 2, 2026
Merged

acrylJonny merged 5 commits into
masterfrom
boomi/00-jdbc

Conversation

@acrylJonny

@acrylJonny acrylJonny commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds datahub.ingestion.source.common.jdbc, a small shared JDBC URL parser, so connectors stop carrying their own copies. The Boomi connector stack (#20888, #20889, #20891) is the first new user.

What moved

From kafka_connect/common.py and kafka_connect/source_connectors.py into common/jdbc.py:

  • normalize_jdbc_url, validate_jdbc_url, JDBC_PREFIX
  • the Oracle thin, SQL Server and jTDS regexes
  • the db2 / teradata / cassandra protocol fallback set

kafka_connect imports them from the new module. Its behaviour is unchanged, and the normalize/validate unit tests moved to tests/unit/common/test_jdbc.py.

New: parse_jdbc_url

Returns a JdbcUrlInfo with platform, host, port, database and schema_name. The platform comes from JDBC_SCHEME_PLATFORMS, an exact match on the JDBC subprotocol (jdbc:postgresql to Redshift hosts, including Serverless, maps to redshift). Athena and BigQuery URLs carry driver properties where the host goes, so only their platform is returned. Multi-host URLs report the first host.

Formats covered:

  • postgres (and redshift by host), redshift, mysql, mariadb, db2: database from //host:port/db
  • SQL Server (;databaseName= or ;database=) and jTDS
  • Oracle thin (@host:port:SID, @//host:port/service): the SID or service goes in database, and the caller decides whether to use it
  • Snowflake (?db=...&schema=...)
  • SAP HANA (jdbc:sap://...?databaseName=..., mapped to hana)
  • Teradata (/DATABASE=db,...)
  • ClickHouse, Vertica, Hive (/db), Trino and Presto (/catalog/schema)

An unknown subprotocol returns no platform, and input it can't parse returns an empty result rather than raising.

Testing

  • tests/unit/common/test_jdbc.py: parametrised over the formats above, plus invalid input
  • tests/unit/kafka_connect passes unchanged

🤖 Generated with Claude Code


Summary by cubic

Extracts JDBC URL parsing from kafka_connect into a new shared common/jdbc module so other connectors can reuse it without changing kafka_connect's behavior.

  • Moves normalize_jdbc_url, validate_jdbc_url, JDBC_PREFIX, the Oracle/SQL Server/jTDS regexes, and the db2/teradata/cassandra platform fallbacks to the new module; the unit tests move with them.
  • Adds parse_jdbc_url, which returns JdbcUrlInfo (platform, host, port, database, schema) for common databases. The jdbc: prefix and subprotocol match case-insensitively, driver-mode qualifiers like mysql:loadbalance are stripped, and platforms come from an exact-match scheme map. Unknown subprotocols yield no platform, unparseable input returns an empty result, and credentials in the authority are dropped. Athena and BigQuery URLs return only their platform, multi-host URLs report the first host, and jdbc:postgresql hosts with Redshift markers map to redshift. SQL Server parsing skips a blank databaseName so a later database resolves, while normalize_jdbc_url keeps first-match behavior.

Written for commit 6f8a8f0. Summary will update on new commits.

View guided diff Turn on auto-fix

@github-actions github-actions Bot added the ingestion PR or Issue related to the ingestion of metadata label Nov 2, 2026
@cursor

cursor Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Extracts JDBC URL handling from Kafka Connect into shared common/jdbc. normalize_jdbc_url, validate_jdbc_url, related constants/regexes, and platform fallbacks move out of kafka_connect/common.py; source and sink connectors import the new module. Kafka Connect behavior stays the same, including normalize_jdbc_url's first-match databaseName semantics for SQL Server (documented as a dependency).

Adds parse_jdbc_url returning JdbcUrlInfo (platform, host, port, database, schema). It supports many JDBC formats (Postgres/Redshift—including postgresql:// Redshift hosts—MySQL/MariaDB with load-balance/iam qualifiers, SQL Server/jTDS, Oracle thin, Snowflake/HANA/Teradata query or path conventions, Trino/Presto catalog/schema paths, Athena/BigQuery property-style authorities, multi-host first-host selection, case-insensitive schemes). Unknown subprotocols omit platform; bad input yields empty JdbcUrlInfo without raising.

Tests: normalize/validate cases relocate to tests/unit/common/test_jdbc.py with broad parse_jdbc_url parametrization; Kafka Connect JDBC factory tests drop duplicated normalize/validate cases.

Reviewed by Cursor Bugbot for commit 6f8a8f0. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.14815% with 3 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...estion/src/datahub/ingestion/source/common/jdbc.py 98.11% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@acrylJonny
acrylJonny added this pull request to stack #20895 November 2, 2026 20:10

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@datahub-connector-tests

datahub-connector-tests Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Connector Tests Results

All connector tests passed for commit 6f8a8f0

View full test logs →

To skip connector tests, add the skip-connector-tests label (org members only).

Autogenerated by the connector-tests CI pipeline.

@maggiehays maggiehays added the needs-review Label for PRs that need review from a maintainer. label Nov 3, 2026
@naeemdh
naeemdh requested a review from rajatoss December 1, 2026 15:03

@rajatoss rajatoss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clean extraction — great to have a shared JDBC parser out of kafka_connect while keeping existing behavior intact. Left a few small comments on edge cases in common/jdbc.py (awsathena/bigquery authorities, _JTDS_RE host group, and portless multi-host URLs).

One small note on the PR description too: it still mentions sqlalchemy_uri_mapper, which commit 6870649 replaced with JDBC_SCHEME_PLATFORMS — worth updating so the PR history stays accurate.

@rajatoss

rajatoss commented Dec 2, 2026

Copy link
Copy Markdown
Member

Please see the comments, APPROVED

acrylJonny and others added 3 commits December 2, 2026 08:52
Move normalize_jdbc_url, validate_jdbc_url, JDBC_PREFIX, the Oracle thin,
SQL Server and jTDS regexes, and the JDBC protocol platform fallback set
from kafka_connect into datahub.ingestion.source.common.jdbc so other
connectors can reuse them. kafka_connect now imports them from there with
no behaviour change; its normalize/validate unit tests move with them.

Add parse_jdbc_url, which returns a JdbcUrlInfo (platform, host, port,
database, schema_name). The platform comes from the SQLAlchemy URI mapper,
with overrides for sap (hana) and mariadb and the existing db2, teradata
and cassandra fallbacks. It covers postgres, redshift, mysql, mariadb, db2,
SQL Server, jTDS, Oracle thin, Snowflake, SAP HANA, Teradata, ClickHouse,
Vertica, Trino, Presto and Hive URLs, returns no platform for an unknown
subprotocol and an empty result for input it cannot parse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parse_jdbc_url now drops driver-mode qualifiers such as mysql:loadbalance,
redshift:iam and clickhouse:http(s) before parsing, so the token is no
longer read as the database. The jdbc: prefix and subprotocol are matched
case-insensitively while host and database keep their case. Platforms come
from an explicit subprotocol map instead of the SQLAlchemy prefix mapper,
so schemes like mysqlx stay unknown. A URL with no authority returns an
empty result.

Oracle, SQL Server and jTDS extraction is shared between
normalize_jdbc_url and parse_jdbc_url; normalize_jdbc_url still reads only
databaseName, so its output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parse_jdbc_url now keeps scanning past an empty databaseName so a later
database parameter still resolves. normalize_jdbc_url keeps its first-match
behaviour so kafka_connect output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8743648. Configure here.

acrylJonny and others added 2 commits December 2, 2026 09:37
Master added a FrozenSet constant to source_connectors.py while this branch
had dropped the import with the JDBC constants it moved out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DBC URLs

- awsathena and bigquery URLs put driver properties or a nested endpoint URL
  where the host goes, so only the platform is returned for them; any other
  authority that parses to a `key=value` or `;` list yields no host.
- Multi-host URLs report the first host and its own port, with or without a
  port on the first host.
- jdbc:postgresql URLs to Redshift Serverless endpoints map to Redshift.
- A portless jTDS URL followed by `;properties` no longer folds them into
  the host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@acrylJonny
acrylJonny merged commit 0f6564e into master Dec 2, 2026
146 checks passed
@acrylJonny
acrylJonny deleted the boomi/00-jdbc branch December 2, 2026 10:05

This branch was successfully deployed

1 active deployment
Preview — 6f8a8f0f Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ingestion PR or Issue related to the ingestion of metadata needs-review Label for PRs that need review from a maintainer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants