mito-ds / mito

The mitosheet package, trymito.io, and other public Mito code.
https://trymito.io
Other
2.29k stars 156 forks source link

Pivot Table Edits: Removing columns from pivot table might delete other columns #1110

Open aarondr77 opened 10 months ago

aarondr77 commented 10 months ago
  1. Create a pivot table with two values
  2. Insert a new column to the end of the pivot table
  3. Open the pivot table configuration and delete the one of the values
  4. Notice that your new column is also gone because it was not able to insert the column at position 4 because the dataframe didn't have 3 columns already.

To fix, if an add column event fails, just add the column using df['New Column Name'] = 0 to add it to the end of the table by default. We would want to handle this inside of the add column step performer.

aarondr77 commented 10 months ago

To get optimized code, we need to call optimize_code_chunks which takes a list of all code chunks and returns an optimized like of code chunks.

It's not obvious that we could just create a new step list from the steps we collect in get_optional_code_to_replay_on_pivot because the post_state and prev_state would not match whenever there is a step in between that does not edit the pivot table.

However, those steps don't matter for the calculating the state of the pivot table, unless there is a VLOOKUP function in the pivot table that needs to access data from another sheet.

aarondr77 commented 10 months ago

Does the post_state need to match the prev_state of the next step in order to generate correct code? I don't think so. If we just used the prev_state and post_state that is stored in the original step list we would get the correct code. I think ...

naterush commented 9 months ago

This should be at least improved by #1115