Skip to content
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

fix(weave_query): prevent table state loss when encountering a new logged column #3060

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

domphan-wandb
Copy link
Contributor

@domphan-wandb domphan-wandb commented Nov 22, 2024

Description

There was a user experience issue causing a table's state (derived columns, sorting, etc) to be wiped when the user logged an additional column with their table in a subsequent run.

Initially I couldn't reproduce it, but realized the issue only occurs after the first new column is added-- subsequent added columns did not reset the table state.

Root cause: the typeShapesMatch util function (only used to determine if tableState should be migrated) does not handle the case of a type being a union<typedDict, typedDict> and the toType being a typedDict where the union members match the property types of the toType's typedDict.

This fix adds a check when the toType is a typedDict and the type is a union<typedDict>. It uses the existing typedDict checking logic to confirm all the members of the union are compatible. I also refactored some of the conditional checks to make it a bit more readable.

I also need to note that the existing behavior did not correctly check the case where two unions are passed in. It will by default return true. In order to reduce the chances of shipping a regression, I've left that untouched and left a comment in the code.

Screen.Recording.2024-11-22.at.11.48.37.AM.mov

Testing

  • Unit tests
  • Local dev QA

@domphan-wandb domphan-wandb requested review from a team as code owners November 22, 2024 16:54
@circle-job-mirror
Copy link

circle-job-mirror bot commented Nov 22, 2024

@domphan-wandb domphan-wandb force-pushed the dom/fix-table-state branch 4 times, most recently from 9b32a0d to 1868d0a Compare November 23, 2024 00:32
}

// 2024/11/20, Note from Dom:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment could be made more actionable by describing what case we return true here

if (isList(type) || isList(toType)) {
if (!isList(type) || !isList(toType)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird...

Comment on lines +94 to 106
if (isTypedDict(type) || isTypedDict(toType)) {
// Handle union<typedDict> case
//
// This is meant for special cases where a user adds another column to their table
// in a subsequent run.
if (isTypedDict(toType) && isUnion(type)) {
return type.members.every(
member =>
isTypedDict(member) &&
isTypedDict(toType) &&
propertyTypesAreCompatible(member, toType)
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything else is just refactor (?), this lgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, besides the union checking code, I refactored to make it a bit more readable. Hope it didn't make the review hard to parse. Thanks for reviewing my PRs, @gtarpenning , I appreciate it! 🙏

Copy link
Contributor

@dannygoldstein dannygoldstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice pr! love the thorough tests and extensive write up. this pr was a pleasure to review

my one comment is that we should rename this function from typeShapesMatch to something else, like isConcattable or something (i leave it to you to think up a better name). as it stands, this function is somewhere in between isAssignable() and typeShapesMatch(): it does not check strict type shape equality (the toType can have less columns than the fromType), but it is also not checking assignability (it would return true for string <- number).

@domphan-wandb
Copy link
Contributor Author

nice pr! love the thorough tests and extensive write up. this pr was a pleasure to review

my one comment is that we should rename this function from typeShapesMatch to something else, like isConcattable or something (i leave it to you to think up a better name). as it stands, this function is somewhere in between isAssignable() and typeShapesMatch(): it does not check strict type shape equality (the toType can have less columns than the fromType), but it is also not checking assignability (it would return true for string <- number).

Thanks Danny! I'm bad at naming things, so I renamed it to typesAreConcattable 👍

@domphan-wandb domphan-wandb merged commit a18cf9d into master Nov 26, 2024
114 of 115 checks passed
@domphan-wandb domphan-wandb deleted the dom/fix-table-state branch November 26, 2024 20:15
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants