-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[no-issue]: Fix upserting dynamic columns #4226
Conversation
newColumns[columnName] = table.hasColumn(columnName) | ||
? table.getColumnValues(columnName) // Upserting a column, so fill with current column values | ||
: new Array(table.length()).fill(undefined); // Creating a new column, so fill with undefined | ||
newColumns[columnName] = new Array(table.length()).fill(undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we now re-insert the skipped rows, there's no need for the conditional upsert logic, just overwrite everything and let the skipped rows re-insert themselves if they exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rohan-bes Thanks for adding the unit test and the fix! Just got a minor suggestion, but can pre approve.
@@ -51,7 +51,14 @@ const insertColumns = (table: TransformTable, params: InsertColumnsParams, conte | |||
values, | |||
})); | |||
|
|||
return table.upsertColumns(columnUpserts); | |||
// Drop, then re-insert the original skipped rows | |||
const rowsToDrop = Object.keys(skippedRows).map(rowIndexString => parseInt(rowIndexString)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const rowsToDrop = Object.keys(skippedRows).map(rowIndexString => parseInt(rowIndexString)); | |
const rowsToDrop = Object.keys(skippedRows); |
Should keys of skippedRows are number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately even though we set them as numbers, they come out as strings. That's JS for you 🤷
Issue https://beyondessential.slack.com/archives/C01MAA3NKM1/p1665977231627499:
This issue is a bit rare, but when we're using dynamic columns to override an existing column, the old values from the existing column are kept.