Repository navigation
refactor(ingest): extract shared JDBC URL parsing into common/jdbc - #20894
Conversation
PR SummaryOverview Adds Tests: normalize/validate cases relocate to Reviewed by Cursor Bugbot for commit 6f8a8f0. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Connector Tests ResultsAll connector tests passed for commit To skip connector tests, add the Autogenerated by the connector-tests CI pipeline. |
rajatoss
left a comment
There was a problem hiding this comment.
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.
|
Please see the comments, APPROVED |
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>
8eda742 to
8743648
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ 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.
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>

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.pyandkafka_connect/source_connectors.pyintocommon/jdbc.py:normalize_jdbc_url,validate_jdbc_url,JDBC_PREFIXkafka_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_urlReturns a
JdbcUrlInfowithplatform,host,port,databaseandschema_name. The platform comes fromJDBC_SCHEME_PLATFORMS, an exact match on the JDBC subprotocol (jdbc:postgresqlto Redshift hosts, including Serverless, maps toredshift). 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:
//host:port/db;databaseName=or;database=) and jTDS@host:port:SID,@//host:port/service): the SID or service goes indatabase, and the caller decides whether to use it?db=...&schema=...)jdbc:sap://...?databaseName=..., mapped tohana)/DATABASE=db,...)/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_connectinto a new sharedcommon/jdbcmodule so other connectors can reuse it without changing kafka_connect's behavior.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.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.Written for commit 6f8a8f0. Summary will update on new commits.