Google Sheets Sink doesn’t pad columns correctly

Description

When a user tries to write data to a spreadsheet using Google Sheets Sink[1], it gives an error[2] and doesn’t properly adjust the number of columns if it’s larger than the spreadsheet’s default number of columns. User mentions that this seems to be a coding error in the code[3] where extensionSize for sheetsSinkClient.extendDimension [4] is supposed to be the result of subtracting the number of default spreadsheets from that of columns of data, but instead it calculates the difference between the number of columns of data and the number of rows of default spreadsheets, as shown in [5], it's supposed to be like[6].

[1] https://cdap.atlassian.net/wiki/spaces/DOCS/pages/763199542/Google+Sheets+Sink

[2] "Invalid requests[0].updateCells: Attempting to write column: 26, beyond the last requested column of: 25",

[3] https://github.com/data-integrations/google-drive/blob/develop/src/main/java/io/cdap/plugin/google/sheets/sink/GoogleSheetsRecordWriter.java#L156

[4] https://github.com/data-integrations/google-drive/blob/develop/src/main/java/io/cdap/plugin/google/sheets/sink/GoogleSheetsSinkClient.java#L140

[5]

if (record.getHeader().getWidth() > sheetsColumnCount.get(spreadsheetName).get(sheetTitle)) { int extensionSize = record.getHeader().getWidth() - sheetsRowCount.get(spreadsheetName).get(sheetTitle); // snipped }

[6]

if (record.getHeader().getWidth() > sheetsColumnCount.get(spreadsheetName).get(sheetTitle)) { int extensionSize = record.getHeader().getWidth() - sheetsColumnCount.get(spreadsheetName).get(sheetTitle); // snipped }

We will need to add unit tests since there doesn’t seem to be any coverage for these lines.

Release Notes

None

Activity

Show:
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Components

Priority

Created May 2, 2023 at 8:13 AM
Updated May 3, 2023 at 9:11 PM

Flag notifications