Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/10262#discussion_r47570429
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
---
@@ -422,7 +422,14 @@ private[sql] class JDBCRDD(
case IntegerConversion => mutableRow.setInt(i, rs.getInt(pos))
case LongConversion => mutableRow.setLong(i, rs.getLong(pos))
// TODO(davies): use getBytes for better performance, if the
encoding is UTF-8
- case StringConversion => mutableRow.update(i,
UTF8String.fromString(rs.getString(pos)))
+ case StringConversion =>
+ val s = rs.getString(pos)
+ if (s != null) {
+ mutableRow.update(i,
UTF8String.fromString(rs.getString(pos).trim))
+ }
+ else {
+ mutableRow.update(i, null)
+ }
--- End diff --
you could just do
```
case StringConversion =>
val newString = Option(rs.getString(pos)).map { s =>
UTF8String.fromString(s.trim) }.orNull
mutableRow.update(i, newString)
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]