urosstan-db commented on code in PR #58762:
URL: https://github.com/apache/spark/pull/58762#discussion_r3997164122
##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -4542,6 +4542,12 @@
],
"sqlState" : "46121"
},
+ "INVALID_JDBC_PARTITION_BOUND" : {
+ "message" : [
+ "Cannot parse the value <value> for JDBC option <option> as <dataType>."
+ ],
+ "sqlState" : "42616"
Review Comment:
Using `42616` ("Invalid options specified") here. Summary of the SQLSTATE
investigation:
- The closest existing precedents are [Avro Boolean option
parsing](https://github.com/apache/spark/blob/abe545ff475f938c06b778c265675c103e2c58a8/connector/avro/src/test/scala/org/apache/spark/sql/avro/AvroSuite.scala#L3289)
and [Protobuf Boolean/integer option
parsing](https://github.com/apache/spark/blob/abe545ff475f938c06b778c265675c103e2c58a8/connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/utils/ProtobufOptions.scala#L37).
Both report `STDS_INVALID_OPTION_VALUE.WITH_MESSAGE`, whose [SQLSTATE is
`42616`](https://github.com/apache/spark/blob/abe545ff475f938c06b778c265675c103e2c58a8/common/utils/src/main/resources/error/error-conditions.json#L7772).
The state data source also uses this family for invalid option values.
- Other formats are mixed: CSV quote/escape length and `lineSep` validation,
and CSV/JSON charset validation, use `22023`; Parquet/ORC unavailable-codec
errors use `56038`. There is no single SQLSTATE used for all data-source option
errors.
JDBC has many checks, but its most comparable validations still have no
SQLSTATE:
| Validation | Existing error | SQLSTATE |
|---|---|---|
| Invalid integer options (`numPartitions`, `queryTimeout`, `fetchsize`,
`batchsize`) | Direct `.toInt` / `NumberFormatException` | None |
| `batchsize < 1`, missing required partition options, or lower bound
greater than upper bound | `require` / `IllegalArgumentException` | None |
| Invalid `isolationLevel` | `_LEGACY_ERROR_TEMP_2081` | None |
| Write `numPartitions <= 0` | `_LEGACY_ERROR_TEMP_2087` | None |
| Conflicting, missing, or empty `dbtable` / `query` |
`_LEGACY_ERROR_TEMP_2078` through `2080` | None |
| Null option value | `NULL_DATA_SOURCE_OPTION` | `22024` |
| `hint` unsupported by the dialect | `HINT_UNSUPPORTED_FOR_JDBC_DIALECT` |
`42822` |
Sources:
[JDBCOptions](https://github.com/apache/spark/blob/abe545ff475f938c06b778c265675c103e2c58a8/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala#L55),
[bound
ordering](https://github.com/apache/spark/blob/abe545ff475f938c06b778c265675c103e2c58a8/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRelation.scala#L112),
[write partition
count](https://github.com/apache/spark/blob/abe545ff475f938c06b778c265675c103e2c58a8/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala#L932),
and [legacy error
definitions](https://github.com/apache/spark/blob/abe545ff475f938c06b778c265675c103e2c58a8/common/utils/src/main/resources/error/error-conditions.json#L11121).
The legacy conditions omit SQLSTATE; using `SparkIllegalArgumentException`
does not supply one implicitly.
Schema-valued JDBC options reuse parser/schema errors:
`createTableColumnTypes` has syntax errors (`42601`), duplicate columns
(`42711`), and unsupported types (`0A000`), as covered in
[JDBCWriteSuite](https://github.com/apache/spark/blob/abe545ff475f938c06b778c265675c103e2c58a8/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCWriteSuite.scala#L508).
The nearby `JdbcDialects.getBuiltInDialect` API uses `22023` for unknown
names, but that validates an API argument, not a data-source option.
So this choice follows the Avro/Protobuf option-conversion precedent, not an
established JDBC convention. `22023` ("invalid parameter value") is the more
portable standard category; `42616` is DB2-origin and nonstandard, but already
established in Spark for this kind of option validation. The JDBC-specific
condition preserves the option name, rejected value, and expected type.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]