codeant-ai-for-open-source[bot] commented on code in PR #37561:
URL: https://github.com/apache/superset/pull/37561#discussion_r2767356200
##########
superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx:
##########
@@ -353,8 +353,11 @@ export default function TableChart<D extends DataRecord =
DataRecord>(
);
const timestampFormatter = useCallback(
- value => getTimeFormatterForGranularity(timeGrain)(value),
- [timeGrain],
+ value =>
+ getTimeFormatterForGranularity(isRawRecords ? undefined : timeGrain)(
+ value,
+ ),
Review Comment:
**Suggestion:** In "raw records" mode the timestamp formatter still routes
values through `getTimeFormatterForGranularity` (with an `undefined` grain),
which can still reformat or timezone-shift the value instead of showing the raw
timestamp string, contradicting the intended "display raw values as-is"
behavior and causing labels to diverge from the actual cell contents; you
should bypass the time formatter entirely when in raw mode and just stringify
the value. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Cross-filter labels show formatted timestamps incorrectly.
- ⚠️ Filter UI mismatches raw table cell display.
- ⚠️ Drill-to-detail / dataMask labels may be confusing.
```
</details>
```suggestion
(value: DataRecordValue) =>
isRawRecords
? String(value ?? '')
: getTimeFormatterForGranularity(timeGrain)(value),
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open the file
superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx and
inspect the timestampFormatter definition at lines 355-361. It calls
getTimeFormatterForGranularity(isRawRecords ? undefined : timeGrain)(value)
(lines
355-361).
2. Create or open a Raw Data - Interactive Table chart (the UI path that
renders
TableChart with props where isRawRecords === true). Ensure the dataset
contains a temporal
column (the column that will be treated as DTTM_ALIAS).
3. Enable cross-filtering (emitCrossFilters true) and click a temporal cell
in the
rendered table. The cell onClick handler in the Cell renderer
(TableChart.tsx, inside the
returned Cell component) calls toggleFilter(key, value) when
emitCrossFilters is true and
conditions match (see cellProps.onClick in the Cell implementation).
4. toggleFilter invokes getCrossFilterDataMask (defined in the same file)
which builds
labelElements via filterValues.map(value => isTimestamp ?
timestampFormatter(value) :
value). Because timestampFormatter (lines 355-361) calls
getTimeFormatterForGranularity
with undefined when isRawRecords is true, the timestamp value still goes
through a
granularity-aware formatter and can be
reformatted/truncated/timezone-shifted. Observe
that the label shown in the dataMask / cross-filter UI (and any filter
labels constructed
from labelElements) contains a formatted date that differs from the raw cell
text the user
saw. This reproduces the mismatch described.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
**Line:** 356:359
**Comment:**
*Logic Error: In "raw records" mode the timestamp formatter still
routes values through `getTimeFormatterForGranularity` (with an `undefined`
grain), which can still reformat or timezone-shift the value instead of showing
the raw timestamp string, contradicting the intended "display raw values as-is"
behavior and causing labels to diverge from the actual cell contents; you
should bypass the time formatter entirely when in raw mode and just stringify
the value.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
```
</details>
--
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]