You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "yadavay-amzn (via GitHub)" <gi...@apache.org> on 2026/04/18 22:59:19 UTC
[PR] [SPARK-55830][SQL] Fix JDBC predicate pushdown dropping driver properties [spark]
yadavay-amzn opened a new pull request, #55408:
URL: https://github.com/apache/spark/pull/55408
## What changes were proposed in this pull request?
When using `spark.read.jdbc()` with predicates, custom JDBC driver properties (like `socketFactory`, `cloudSqlInstance`) were silently dropped, causing connection failures. Without predicates, the same properties worked fine.
### Root Cause
In `JDBCOptions`, the constructor `this(url, table, parameters: Map[String, String])` did:
```scala
this(CaseInsensitiveMap(parameters ++ Map(JDBC_URL -> url, JDBC_TABLE_NAME -> table)))
```
When `parameters` is a `CaseInsensitiveMap` (which it is in the predicate code path), `parameters ++ Map(...)` calls the **inherited** `Map.++` (because the static type is `Map[String, String]`). The inherited `Map.++` iterates `this` using `CaseInsensitiveMap.iterator`, which returns **lowercased keys** from `keyLowerCasedMap`. This creates a plain `HashMap` with lowercased keys, losing the original case.
JDBC drivers expect case-sensitive property names (e.g., `socketFactory`, not `socketfactory`), so `asConnectionProperties` returns properties with wrong-cased keys, and `Properties.getProperty("socketFactory")` returns `null`.
### Fix
Wrap `parameters` in `CaseInsensitiveMap` first, then use `CaseInsensitiveMap.++` which preserves original key case via the `updated()` method:
```scala
this(CaseInsensitiveMap(parameters) ++ Map(JDBC_URL -> url, JDBC_TABLE_NAME -> table))
```
Applied to both `JDBCOptions` and `JdbcOptionsInWrite`.
## How was this patch tested?
Added a unit test in `JDBCSuite` that simulates the predicate code path: creates `JDBCOptions` from `CaseInsensitiveMap ++ Properties.asScala` and verifies `asConnectionProperties` preserves original key case.
## Does this PR introduce _any_ user-facing change?
Yes. Custom JDBC driver properties (e.g., `socketFactory`, `cloudSqlInstance`) now work correctly when using `spark.read.jdbc()` with predicates.
### Was this patch authored or co-authored using generative AI tooling?
Yes
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-55830][SQL] Fix JDBC predicate pushdown dropping driver properties [spark]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #55408:
URL: https://github.com/apache/spark/pull/55408#issuecomment-5376711990
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-55830][SQL] Fix JDBC predicate pushdown dropping driver properties [spark]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #55408: [SPARK-55830][SQL] Fix JDBC predicate pushdown dropping driver properties
URL: https://github.com/apache/spark/pull/55408
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-55830][SQL] Fix JDBC predicate pushdown dropping driver properties [spark]
Posted by "yadavay-amzn (via GitHub)" <gi...@apache.org>.
yadavay-amzn commented on PR #55408:
URL: https://github.com/apache/spark/pull/55408#issuecomment-4435596626
@cloud-fan @pan3793 Could you take a look when you get a chance? This fixes JDBC predicate pushdown silently dropping driver properties when building the connection. CI is green (29/29 jobs passing).
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org