You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behaviour: CSV with empty last column would load successfully when SQLServerBulkCSVFileRecord.setEscapeColumnDelimitersCSV(true).
Actual behaviour: Exception thrown because number of columns in data does not match number of columns in header
Error message/stack trace:
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: Unable to retrieve data from the source.
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeBatchData(SQLServerBulkCopy.java:3626)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.doInsertBulk(SQLServerBulkCopy.java:1566)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.access$300(SQLServerBulkCopy.java:64)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy$1InsertBulk.doExecute(SQLServerBulkCopy.java:662)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7375)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3206)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.sendBulkLoadBCP(SQLServerBulkCopy.java:696)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:1654)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:619)
... 2 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Source data does not match source schema.
at com.microsoft.sqlserver.jdbc.SQLServerBulkCSVFileRecord.getRowData(SQLServerBulkCSVFileRecord.java:267)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeBatchData(SQLServerBulkCopy.java:3623)
... 10 more
Any other details that can be helpful: -1 needs to be added to the split invocation at line 200 and 247 of SQLServerBulkCSVFileRecord.java to mirror the split invocation when escapeDelimiters is false, otherwise blank columns at the end of the line are dropped. E.g., escapeQuotesRFC4180(currentLine.split(delimiter + escapeSplitPattern, -1))
Driver version
8.4.1
SQL Server version
Microsoft SQL Server 2016 (SP2-CU8) (KB4505830) - 13.0.5426.0 (X64)
Client Operating System
Windows 10
JAVA/JVM version
Amazon Corretto 11
Table schema
Problem description
SQLServerBulkCSVFileRecord.setEscapeColumnDelimitersCSV(true)
.-1
needs to be added to thesplit
invocation at line 200 and 247 of SQLServerBulkCSVFileRecord.java to mirror thesplit
invocation whenescapeDelimiters
isfalse
, otherwise blank columns at the end of the line are dropped. E.g.,escapeQuotesRFC4180(currentLine.split(delimiter + escapeSplitPattern, -1))
Reproduction code
The text was updated successfully, but these errors were encountered: