bito-code-review[bot] commented on PR #40859:
URL: https://github.com/apache/superset/pull/40859#issuecomment-4651463827
<!-- Bito Reply -->
The flagged issue is correct. The `csv.df_to_escaped_csv` function relies on
positional indexing (`df.at[idx, ...]`) which assumes a `RangeIndex` (0 to
N-1). When `processed_df` has a non-default index (such as a `MultiIndex` or
string labels from pivot operations), these positional writes fail to target
the correct rows, leading to data misalignment or duplication.
To resolve this, you should avoid positional mutation and instead use
label-based iteration or create a copy of the DataFrame with a reset index
before processing. A concise fix is to reset the index before passing the
DataFrame to the escaping function:
```python
# In superset/charts/client_processing.py
# Route through the formula-escaping CSV writer
query["data"] = csv.df_to_escaped_csv(
processed_df.reset_index(), index=show_default_index
)
```
This ensures the escaping logic operates on a standard `RangeIndex`,
preserving the data integrity of the original labels which are now columns.
**superset/charts/client_processing.py**
```
# Route through the formula-escaping CSV writer
query["data"] = csv.df_to_escaped_csv(
processed_df.reset_index(), index=show_default_index
)
```
--
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]