SEPURI-SAI-KRISHNA commented on code in PR #45439:
URL: https://github.com/apache/superset/pull/45439#discussion_r4320934024


##########
superset/charts/client_processing.py:
##########
@@ -1246,15 +1302,37 @@ def label_of(name: str) -> str:
             if configured_currency.get("symbol")
             else currency_by_label.get(column) or {}
         )
+        # The small-number format has no dataset-level counterpart, and the
+        # browser pairs it with the column config's own currency rather than
+        # the resolved one, so both come straight from ``config``. A cleared
+        # Select leaves a blank string behind, which the browser treats as
+        # unset.
+        small_number_format = (config.get("d3SmallNumberFormat") or 
"").strip() or None
 
         is_number = pd.api.types.is_numeric_dtype(df[column])
 
         if column in percent_metric_labels:
-            format_column(df, column, number_format or PERCENT_3_POINT, {})
+            format_column(
+                df,
+                column,
+                number_format or PERCENT_3_POINT,
+                {},
+                small_d3_format=small_number_format,
+                small_currency=configured_currency,

Review Comment:
   Confirmed, and fixed in the commit above.
   
   I checked the browser side to be sure the row context really does reach that 
formatter. `formatColumnValue` builds the small-number formatter from the 
column meta without looking at `isPercentMetric`:
   
   ```ts
   const smallNumberFormatter = getSmallNumberFormatter(
     formatter,
     config.d3SmallNumberFormat,
     config.currencyFormat,
   );
   ```
   
   and `getSmallNumberFormatter` returns a `CurrencyFormatter` whenever 
`currencyFormat` is set, which makes `formatValue` take its `formatter 
instanceof CurrencyFormatter` branch and pass `rowData` plus 
`currencyCodeColumn`. So a percent metric's small cells do resolve AUTO per 
row, while its normal cells go through `getNumberFormatter(numberFormat || 
PERCENT_3_POINT)` and carry no currency at all.
   
   The call now passes the context:
   
   ```python
           if column in percent_metric_labels:
               # A percent metric's own formatter never carries a currency, but
               # ``getSmallNumberFormatter`` still builds one from the column
               # config, so the small-number cells need the row's context too.
               format_column(
                   df,
                   column,
                   number_format or PERCENT_3_POINT,
                   {},
                   currency_context=row_currency_context,
                   small_d3_format=small_number_format,
                   small_currency=configured_currency,
               )
   ```
   
   One difference from the numeric call below: I left `fallback_to_detected` 
off rather than setting it to `False`. It would be inert here. The normal path 
passes `{}` as the currency, and `resolve_auto_currency` returns on its first 
line for anything that is not AUTO, so the flag is never read; the small path 
inside `format_column` already hardcodes `fallback_to_detected=False`. Adding 
it would read as if it did something.
   
   Your exact scenario is the new test. Against the parent commit it fails with 
`0.500` where the numeric column gives `$ 0.500`.



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