33modeling opened a new pull request, #45441:
URL: https://github.com/apache/superset/pull/45441

   ### SUMMARY
   
   CSV export can overwrite distinct cells when row labels or column names 
repeat. `df_to_escaped_csv` assigns each escaped string through `.at`, which 
selects every matching label when either axis is non-unique. Escaping headers 
can also turn two originally distinct column names into the same label.
   
   Address each cell by row and column position instead. The regression tests 
cover repeated labels on either axis, duplicate MultiIndex labels, 
escaped-header collisions, nullable integers and mixed object values, with 
pandas copy-on-write both enabled and disabled.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   For `pd.DataFrame({"value": ["first", "=1+1"]}, index=[7, 7])`, exported 
without the index:
   
   ```text
   Before (copy-on-write disabled):
   value
   first
   first
   
   After:
   value
   first
   '=1+1
   ```
   
   With copy-on-write enabled, the original code instead exports the escaped 
formula twice. The corrected output preserves both cells in either mode.
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest tests/unit_tests/utils/csv_tests.py 
tests/unit_tests/utils/excel_tests.py 
tests/unit_tests/charts/test_client_processing.py -q
   pre-commit run
   pylint --rcfile=.pylintrc --load-plugins=superset.extensions.pylint 
--reports=no superset/utils/csv.py
   ```
   
   - All 14 new regression cases fail against the original implementation.
   - With the fix: 28 CSV tests pass; the three export-related files above 
total 150 passing tests.
   - Staged-file pre-commit checks, including mypy and Ruff, pass. Direct 
Pylint reports no findings.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to