SEPURI-SAI-KRISHNA opened a new issue, #45409:
URL: https://github.com/apache/superset/issues/45409

   ### Bug description
   
   `table()` in `superset/charts/client_processing.py` is the backend mirror of 
the
   Table plugin's column formatting, used for `POST_PROCESSED` chart data, 
which is
   the table body of text-content email and Slack reports. It applies
   `d3NumberFormat` and `currencyFormat` from a column's `column_config`, but 
there
   is no `d3TimeFormat` branch at all. A column with an explicit time format is
   left unformatted in the report, while the browser applies it.
   
   The browser formats the temporal column in the first branch of
   `plugin-chart-table/src/transformProps.ts`:
   
   ```ts
   if (isTime || config.d3TimeFormat) {
     const customFormat = config.d3TimeFormat || savedFormat;
     const timeFormat = customFormat || tableTimestampFormat;
     ...
     formatter = getTimeFormatter(timeFormat);
   }
   ```
   
   ### Reproduction
   
   1. Build a Table chart with a temporal column `ds` and set its column format 
to
      `%Y` (Customize > Column config > `d3TimeFormat`).
   2. Attach it to an email or Slack report (text/table content, not CSV/XLSX).
   3. The report's table shows the full timestamp (e.g. `2024-01-15 13:45:00`)
      instead of `2024`. In the browser the same column shows `2024`.
   
   ### Where it happens
   
   The per-column loop in `table()` reads only number and currency formats:
   
   ```python
   number_format = config.get("d3NumberFormat") or 
number_format_by_label.get(column)
   currency = (configured_currency if configured_currency.get("symbol")
               else currency_by_label.get(column) or {})
   ```
   
   There is no read of `config.get("d3TimeFormat")` anywhere in the file, so a
   temporal column is never formatted.
   
   ### Expected behaviour
   
   A column with an explicit `d3TimeFormat` is formatted in the report the same 
way
   the browser formats it, instead of being left raw.
   
   ### Scope
   
   This is about the explicit per-column `d3TimeFormat`. The browser's wider
   behaviour (the bare `isTime` case that formats temporal columns with no 
config,
   the `tableTimestampFormat` default, the `SMART_DATE` granularity fallback, 
and
   time-formatting of string columns) is a much larger change and is left for a
   follow-up; it needs a full server-side d3-time-format port rather than the
   subset of directives Python's `strftime` shares with d3.
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.11
   
   ### Node version
   
   Not applicable
   
   ### Browser
   
   Not applicable
   
   ### Additional context
   
   Verified against `master` at `a5d29a9d27`. With
   `column_config = {"ds": {"d3TimeFormat": "%Y"}, "SUM(num)": 
{"d3NumberFormat": ",.2f"}}`,
   `table()` leaves `ds` as `2024-01-15 13:45:00` while formatting `SUM(num)`,
   confirming formatting is active on the call and only the time column is 
skipped.
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [x] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.
   


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