aglinxinyuan opened a new pull request, #5698:
URL: https://github.com/apache/texera/pull/5698
### What changes were proposed in this PR?
Pin the JDBC URL composition for the two SQL-source connection helpers in
`common/workflow-operator/operator/source/sql/{postgresql,mysql}/` without
standing up a real DB. No production-code changes.
| Spec | Source class | Tests |
| --- | --- | --- |
| `PostgreSQLConnUtilSpec` | `PostgreSQLConnUtil` | 8 |
| `MySQLConnUtilSpec` | `MySQLConnUtil` | 8 |
Both spec files follow the `<srcClassName>Spec.scala` one-to-one convention.
**Behavior pinned — `PostgreSQLConnUtil`**
| Surface | Contract |
| --- | --- |
| URL format | `jdbc:postgresql://{host}:{port}/{database}` (exact
substring) |
| Host/port/database interpolation | distinct values reach their slots; host
BEFORE port |
| Subprotocol | `jdbc:postgresql:`, never `jdbc:mysql:` |
| Empty database name | produces a well-formed
`jdbc:postgresql://{host}:{port}/` URL |
| Credentials | `user` / `password` reach the driver via `Properties` |
| `setReadOnly(true)` | called on the returned Connection (query-efficiency
contract) |
| `SQLException` | propagated when the driver throws |
**Behavior pinned — `MySQLConnUtil`**
| Surface | Contract |
| --- | --- |
| URL format | `jdbc:mysql://{host}:{port}/{database}?…` (exact substring) |
| Host/port/database interpolation | distinct values reach their slots; host
BEFORE port |
| `autoReconnect=true` query parameter | present (retry-behavior contract) |
| `useSSL=true` query parameter | present (TLS contract — drift here would
silently downgrade security) |
| `?` / `&` separators | canonical
`jdbc:mysql://h:3306/db?autoReconnect=true&useSSL=true` sequence pinned
end-to-end |
| Subprotocol | `jdbc:mysql:`, never `jdbc:postgresql:` |
| `SQLException` | declared via `@throws[SQLException]` on the method |
**Test strategy notes**
The harness for each util differs because the test classpath includes the
PostgreSQL driver transitively but no MySQL driver:
- `MySQLConnUtilSpec` lets `DriverManager.getConnection` throw its default
`SQLException("No suitable driver found for " + url)` — the URL is present in
the exception message, and assertions pin substrings.
- `PostgreSQLConnUtilSpec` cannot use that path (the real PostgreSQL driver
intercepts before the "No suitable driver" message can be raised, producing a
generic "The connection attempt failed."). Instead the spec deregisters every
driver that accepts `jdbc:postgresql:`, registers a capturing driver, and
returns a `java.lang.reflect.Proxy`-backed `Connection` so the production code
can call `setReadOnly(true)`. The real drivers are restored in `afterAll`.
### Any related issues, documentation, discussions?
Closes #5695.
### How was this PR tested?
Pure unit-test additions; verified locally with:
- `sbt "WorkflowOperator/testOnly
org.apache.texera.amber.operator.source.sql.postgresql.PostgreSQLConnUtilSpec
org.apache.texera.amber.operator.source.sql.mysql.MySQLConnUtilSpec"` — 16
tests, all green
- `sbt scalafmtCheckAll` — clean
- CI to confirm
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.7 [1M context])
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]