Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/14502#discussion_r73737921
--- Diff: core/src/main/scala/org/apache/spark/rdd/JdbcRDD.scala ---
@@ -79,12 +79,17 @@ class JdbcRDD[T: ClassTag](
val conn = getConnection()
val stmt = conn.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY)
- // setFetchSize(Integer.MIN_VALUE) is a mysql driver specific way to
force streaming results,
- // rather than pulling entire resultset into memory.
- // see
http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-implementation-notes.html
- if (conn.getMetaData.getURL.matches("jdbc:mysql:.*")) {
+ val url = conn.getMetaData.getURL
+ if (url.startsWith("jdbc:mysql:")) {
+ // setFetchSize(Integer.MIN_VALUE) is a mysql driver specific way to
force streaming results,
+ // rather than pulling entire resultset into memory.
+ // see
https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-implementation-notes.html
+
stmt.setFetchSize(Integer.MIN_VALUE)
- logInfo("statement fetch size set to: " + stmt.getFetchSize + " to
force MySQL streaming ")
+ logInfo("statement fetch size set to: " + stmt.getFetchSize + " to
force MySQL streaming")
+ } else {
+ stmt.setFetchSize(100)
+ logInfo("statement fetch size set to: " + stmt.getFetchSize + " to
force streaming")
--- End diff --
Nit: you could use string interpolation in both statements. Also, it's not
really streamed a record at a time in this case here. Maybe just log the
statement fetch size.
---
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]