-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18413][SQL] Add maxConnections JDBCOption
#15868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
57b10ec
bf1d6bd
28718d0
0391dbf
ca75a4e
cbb74d9
dc152f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -667,7 +667,14 @@ object JdbcUtils extends Logging { | |
| val getConnection: () => Connection = createConnectionFactory(options) | ||
| val batchSize = options.batchSize | ||
| val isolationLevel = options.isolationLevel | ||
| df.foreachPartition(iterator => savePartition( | ||
| val maxConnections = options.maxConnections | ||
| val repartitionedDF = | ||
| if (maxConnections != null && maxConnections.toInt < df.rdd.getNumPartitions) { | ||
|
||
| df.coalesce(maxConnections.toInt) | ||
| } else { | ||
| df | ||
| } | ||
| repartitionedDF.foreachPartition(iterator => savePartition( | ||
| getConnection, table, iterator, rddSchema, nullTypes, batchSize, dialect, isolationLevel) | ||
| ) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should avoid using
nullin scala, how about makemaxConnectionsOption[Int]?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! No problem. I'll update this PR again.