This is an automated email from the ASF dual-hosted git repository.
HyukjinKwon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 5abbd34c8375 [SPARK-58865][SQL] Add an example to the JDBC hint option
error message
5abbd34c8375 is described below
commit 5abbd34c837571b059de659898bbf699f6c6d3fb
Author: Ganesha S <[email protected]>
AuthorDate: Thu Aug 20 16:01:41 2026 +0900
[SPARK-58865][SQL] Add an example to the JDBC hint option error message
### What changes were proposed in this pull request?
The JDBC hint option must be wrapped as /*+ ... */, validated by a regex in
`JDBCOptions`. When validation fails, the error describes the required
delimiters in prose only. This PR adds a concrete example to the message and
updates the assertion in `JDBCSuite` ("SPARK-50666: reading hint test")
accordingly:
Invalid value `<value>` for option `hint`. It should start with `/*+ ` and
end with ` */`, for example `/*+ INDEX(t1 id_idx) */`.
### Why are the changes needed?
The required leading/trailing spaces inside /*+ and */ are easy to miss,
and a worked example is faster to act on than a prose description. This reduces
troubleshooting time for a purely syntactic mistake.
### Does this PR introduce _any_ user-facing change?
Yes. The IllegalArgumentException message for an invalid hint option now
includes an example. Validation behavior is unchanged.
### How was this patch tested?
Updated the existing unit test in JDBCSuite that pins the validation
message; it exercises the three invalid-hint cases (`"INDEX(test idx1) */",
"/*+ INDEX(test idx1)", ""`). No new suite required.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)
Closes #58114 from ganeshashree/SPARK-58865.
Lead-authored-by: Ganesha S <[email protected]>
Co-authored-by: Ganesha S <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
.../org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala | 3 ++-
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala
index 084b192b5763..e4bd4df8cf2f 100644
---
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala
+++
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala
@@ -268,7 +268,8 @@ class JDBCOptions(
val hint = parameters.get(JDBC_HINT_STRING).map(value => {
require(value.matches("(?s)^/\\*\\+ .* \\*/$"),
s"Invalid value `$value` for option `$JDBC_HINT_STRING`." +
- s" It should start with `/*+ ` and end with ` */`.")
+ s" It should start with `/*+ ` and end with ` */`," +
+ s" for example `/*+ INDEX(t1 id_idx) */`.")
s"$value "
}).getOrElse("")
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
index 288871b3b1ce..16f3f697ff17 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
@@ -2875,7 +2875,8 @@ class JDBCSuite extends SharedSparkSession {
"hint" -> hint))
}.getMessage
assert(e.contains(s"Invalid value `$hint` for option `hint`." +
- s" It should start with `/*+ ` and end with ` */`."))
+ s" It should start with `/*+ ` and end with ` */`," +
+ s" for example `/*+ INDEX(t1 id_idx) */`."))
}
// dialect supported check
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]