@@ -276,30 +276,24 @@ object BulkCopyUtils extends Logging {
276276                var  dfFieldIndex  =  0 
277277                var  dfColName : String  =  " " 
278278                if  (isCaseSensitive) {
279-                     if  (! dfCols.fieldNames.contains(tableColName)) {
280-                         if  (strictSchemaCheck) {
281-                             throw  new  SQLException (s " SQL table column  ${tableColName} not exist in df columns " )
282-                         } else  {
283-                             //  when strictSchema check disabled, skip mapping / metadata if table col not in df col
284-                             logDebug(s " skipping index  $i sql col name  $tableColName mapping and column metadata " )
285-                             break
286-                         }
279+                     if  (! strictSchemaCheck &&  ! dfCols.fieldNames.contains(tableColName)) {
280+                         //  when strictSchema check disabled, skip mapping / metadata if table col not in df col
281+                         logDebug(s " skipping index  $i sql col name  $tableColName mapping and column metadata " )
282+                         break
287283                    }
284+                     dfFieldIndex =  dfCols.fieldIndex(tableColName)
288285                    dfColName =  dfCols(dfFieldIndex).name
289286                    assertIfCheckEnabled(
290287                        tableColName ==  dfColName, strictSchemaCheck,
291288                        s """ ${prefix} column names ' ${tableColName}' and 
292289                        ' ${dfColName}' at column index  ${i} (case sensitive) """ )
293290                } else  {
294-                     if  (! dfColCaseMap.contains(tableColName.toLowerCase())) {
295-                         if  (strictSchemaCheck) {
296-                             throw  new  SQLException (s " SQL table column  ${tableColName} not exist in df columns " )
297-                         } else  {
298-                             //  when strictSchema check disabled, skip mapping / metadata if table col not in df col
299-                             logDebug(s " skipping index  $i sql col name  $tableColName mapping and column metadata " )
300-                             break
301-                         }
291+                     if  (! strictSchemaCheck &&  ! dfColCaseMap.contains(tableColName.toLowerCase())) {
292+                         //  when strictSchema check disabled, skip mapping / metadata if table col not in df col
293+                         logDebug(s " skipping index  $i sql col name  $tableColName mapping and column metadata " )
294+                         break
302295                    }
296+                     dfFieldIndex =  dfCols.fieldIndex(dfColCaseMap(tableColName.toLowerCase()))
303297                    dfColName =  dfCols(dfFieldIndex).name
304298                    assertIfCheckEnabled(
305299                        tableColName.toLowerCase() ==  dfColName.toLowerCase(),
0 commit comments