@@ -686,7 +686,10 @@ void handleQueryResult(String query, TableResult results, SqlType queryType)
686686 case DML :
687687 case DML_EXTRA :
688688 QueryStatistics dmlStats = getQueryStatisticsFromJob (results );
689- Long dmlRowCount = (dmlStats != null ) ? dmlStats .getNumDmlAffectedRows () : null ;
689+ Long dmlRowCount =
690+ (dmlStats != null && dmlStats .getNumDmlAffectedRows () != null )
691+ ? dmlStats .getNumDmlAffectedRows ()
692+ : 0L ;
690693 updateAffectedRowCount (dmlRowCount );
691694 break ;
692695 case TCL :
@@ -731,12 +734,12 @@ void handleQueryResult(String query, TableResult results, SqlType queryType)
731734 updateAffectedRowCount (exportRowCount );
732735 break ;
733736 case OTHER :
734- String truncatedQuery =
735- ( query != null && query . length () > 60 ) ? query . substring ( 0 , 60 ) + "..." : query ;
736- String jobId = (results .getJobId () != null ) ? results .getJobId ().getJob () : "unknown" ;
737+ String truncatedQuery = truncateQuery ( query );
738+ String id =
739+ (results .getJobId () != null ) ? results .getJobId ().getJob () : results . getQueryId () ;
737740 LOG .warning (
738- "Encountered unmapped SQL statement type [Job ID: %s]. Treating as update statement: %s" ,
739- jobId , truncatedQuery );
741+ "Encountered unmapped SQL statement type [Job/Query ID: %s]. Treating as update statement: %s" ,
742+ id , truncatedQuery );
740743 updateAffectedRowCount (results .getTotalRows ());
741744 break ;
742745 }
@@ -1618,13 +1621,19 @@ protected void logQueryExecutionStart(String sql) {
16181621 if (sql == null ) {
16191622 return ;
16201623 }
1621- String sanitizedSql = sql .trim ().replaceAll ("\\ s+" , " " );
1622- String truncatedSql =
1623- sanitizedSql .length () > 256 ? sanitizedSql .substring (0 , 256 ) + "..." : sanitizedSql ;
1624+ String truncatedSql = truncateQuery (sql );
16241625 LOG .info ("Executing query: " + truncatedSql );
16251626 LOG .info ("Using query settings: " + this .querySettings .toString ());
16261627 }
16271628
1629+ private String truncateQuery (String sql ) {
1630+ if (sql == null ) {
1631+ return null ;
1632+ }
1633+ String sanitizedSql = sql .trim ().replaceAll ("\\ s+" , " " );
1634+ return sanitizedSql .length () > 256 ? sanitizedSql .substring (0 , 256 ) + "..." : sanitizedSql ;
1635+ }
1636+
16281637 /** Throws a {@link BigQueryJdbcException} if this object is closed */
16291638 void checkClosed () throws SQLException {
16301639 if (isClosed ()) {
0 commit comments