aminghadersohi commented on code in PR #45782:
URL: https://github.com/apache/superset/pull/45782#discussion_r4394830597


##########
superset/utils/csv.py:
##########
@@ -107,13 +108,27 @@ def escape_values(v: Any) -> Union[str, Any]:
     # even when the DataFrame has a non-default index (e.g. the flattened
     # MultiIndex produced by pivot_table_v2 post-processing). Pairing 
positional
     # indices with the label-based ``.at`` accessor would otherwise create
-    # phantom rows and corrupt the output. Only string cells are reassigned, so
-    # the dtype of mixed object columns (e.g. nullable integers) is preserved.
+    # phantom rows and corrupt the output. Numeric dtypes are left for pandas;
+    # object columns need explicit formatting to match streaming CSV exports.
+    decimal_separator = kwargs.get("decimal", ".")
     for name, column in df.items():
         if pd.api.types.is_string_dtype(column.dtype):
             for label, value in column.items():
                 if isinstance(value, str):
                     df.at[label, name] = escape_value(value)
+                elif isinstance(value, Decimal) and value.is_finite():
+                    # Preserve precision and scale without passing numeric text
+                    # through the string formula-prefix escaping path.
+                    df.at[label, name] = format_decimal(value).replace(
+                        ".", decimal_separator
+                    )

Review Comment:
   `pivot` → `flatten` leaves duplicate row labels: Decimal values `1.2500` and 
`2.5000` both export as `1.2500`, even with defaults. The string overwrite is 
pre-existing, but these branches extend it to numeric cells; duplicate verbose 
column labels also corrupt values.



-- 
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