bito-code-review[bot] commented on code in PR #44739:
URL: https://github.com/apache/superset/pull/44739#discussion_r4150649239


##########
superset/commands/sql_lab/export.py:
##########
@@ -140,6 +141,12 @@ def run(
                 self._query.schema,
             )[:limit]
 
+        # Preserve exact decimals without scientific notation in CSV output.
+        for name, column in df.items():
+            for label, value in column.items():
+                if isinstance(value, Decimal) and value.is_finite():
+                    df.at[label, name] = format(value, "f")

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Per-cell .at loop slow</b></div>
   <div id="fix">
   
   This cell-by-cell `df.at` loop visits every cell of every column on every 
export, even when no `Decimal` is present. Measured in this repo's environment 
(pandas 3.0.6): ~1.4s vs ~0.11s for an equivalent vectorized `Series.map` on 
200k object-dtype cells (~13x). SQL Lab CSV export runs synchronously, so large 
row limits stall the request; prefer a per-column `map` pass.
   </div>
   
   
   </div>
   
   
   
   
   
   <div id="suggestion">
   <div id="issue"><b>Formatting logic in run()</b></div>
   <div id="fix">
   
   `run()` now mixes result-fetch I/O, limit business logic, decimal 
presentation formatting, and CSV encoding. `superset/utils/csv.py` already owns 
per-cell CSV value transformation (`df_to_escaped_csv`); hosting the decimal 
formatting there or in a helper keeps the command focused on orchestration and 
gives the transform a single home and test surface.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #1a674f</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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