fatmanverse commented on code in PR #12919:
URL: https://github.com/apache/seatunnel/pull/12919#discussion_r4408092160
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/utils/JdbcFieldTypeUtils.java:
##########
@@ -122,15 +134,45 @@ public static BigDecimal getBigDecimal(
*
* <p>PostgreSQL allows the special numeric values {@code NaN}, {@code
Infinity} and {@code
* -Infinity} (supported since PostgreSQL 14). This method reads the raw
value as a string and
- * reports whether it is one of those special values; it never throws.
+ * reports whether it is one of those special values. In the binary
protocol the driver decodes
+ * the value for {@code getString} as well and fails on {@code Infinity}
and {@code -Infinity},
+ * so the binary representation of the value is inspected instead. It
never throws.
*/
public static boolean isNumericSpecialValue(ResultSet resultSet, int
columnIndex) {
try {
return
isNumericSpecialValueString(resultSet.getString(columnIndex));
+ } catch (SQLException | RuntimeException e) {
Review Comment:
Agreed, thanks. Done in cae8b70: `JdbcFieldTypeUtils` is back to its `dev`
version, so this PR no longer changes the shared utility or what other dialects
catch. The only new catch is in `PostgresJdbcRowConverter#getDecimalValue`, and
it is limited to the `IllegalArgumentException` that pgjdbc's
`ByteConverter.numeric` throws (`invalid sign in "numeric" value`) for a binary
`Infinity` / `-Infinity`. The value is read as `null` only when
`numeric_special_value_as_null` is on and the raw bytes are exactly one of
those two values; any other `IllegalArgumentException` is rethrown unchanged.
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/utils/JdbcFieldTypeUtils.java:
##########
@@ -38,6 +38,16 @@
public final class JdbcFieldTypeUtils {
+ /** A binary PostgreSQL special numeric value consists of the four header
words only. */
Review Comment:
Done in cae8b70: the binary header check moved to
`PostgresJdbcRowConverter#isBinaryNumericInfinity`, with the constants, and the
tests moved to `PostgresJdbcRowConverterTest`
(`testToInternalWithBinaryNumericInfinityAsNull`,
`testToInternalKeepsBinaryNumericInfinityErrorWithoutOption`,
`testToInternalRethrowsBinaryNumericErrorForOrdinaryValue`,
`testIsBinaryNumericInfinity`).
--
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]