HeartSaVioR commented on a change in pull request #26109: [SPARK-29461][SQL] 
Measure the number of records being updated for JDBC writer
URL: https://github.com/apache/spark/pull/26109#discussion_r337855670
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
 ##########
 @@ -673,12 +673,12 @@ object JdbcUtils extends Logging {
           stmt.addBatch()
           rowCount += 1
           if (rowCount % batchSize == 0) {
-            stmt.executeBatch()
+            totalUpdatedRows += stmt.executeBatch().sum
             rowCount = 0
           }
         }
         if (rowCount > 0) {
-          stmt.executeBatch()
+          totalUpdatedRows += stmt.executeBatch().sum
 
 Review comment:
   I took the approach to ensure we only count for actual updates, but not sure 
how Spark has been doing for others. Same for number of bytes written. I was 
actually asked to update number of bytes written as well, but there's no way to 
get the actual value from JDBC, so skipped it. 
   
   Please let me know how Spark has been updating these metrics - I'll follow 
the approach. Thanks!

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to