refactor(ingest): extract shared JDBC URL parsing into common/jdbc
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 indatabase, and the caller decides whether to use it - Snowflake (
?db=...&schema=...) - SAP HANA (
jdbc:sap://...?databaseName=..., mapped tohana) - 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 inputtests/unit/kafka_connectpasses 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 returnsJdbcUrlInfo(platform, host, port, database, schema) for common databases. Thejdbc:prefix and subprotocol match case-insensitively, driver-mode qualifiers likemysql:loadbalanceare 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, andjdbc:postgresqlhosts with Redshift markers map to redshift. SQL Server parsing skips a blankdatabaseNameso a laterdatabaseresolves, whilenormalize_jdbc_urlkeeps first-match behavior.