WhoamiI00 commented on code in PR #43115:
URL: https://github.com/apache/superset/pull/43115#discussion_r3788768075
##########
superset-frontend/src/explore/components/DataTablesPane/components/SamplesPane.tsx:
##########
@@ -105,10 +105,13 @@ export const SamplesPane = ({
1,
)
.then(response => {
- setData(ensureIsArray(response.data));
- setColnames(ensureIsArray(response.colnames));
- setColtypes(ensureIsArray(response.coltypes));
- setRowCount(response.rowcount);
+ // A 200 that carries no `result` payload resolves to undefined here.
+ // Read through it so the pane falls back to its empty state instead
+ // of throwing a TypeError that surfaces as an internal error
message.
+ setData(ensureIsArray(response?.data));
+ setColnames(ensureIsArray(response?.colnames));
+ setColtypes(ensureIsArray(response?.coltypes));
+ setRowCount(response?.rowcount ?? 0);
Review Comment:
Good catch — that was a real regression in the guard. Fixed in d49f741.
`TableControls` renders the label when `rowcount < (rowLimit ?? Infinity)`,
and it only renders at all once `data.length > 0`. So for a response carrying
rows but no `rowcount`, my `?? 0` turned an absent count into a literal `0
rows` label over a populated table — whereas before the change `undefined`
simply hid the label.
It now falls back to the number of rows actually returned:
```ts
const rows = ensureIsArray(response?.data);
...
setRowCount(response?.rowcount ?? rows.length);
```
That's more accurate than either behaviour: the label shows the real count
instead of being hidden. Added a test for it — with the old `?? 0` it fails
with `found <span data-test="row-count-label">0 rows</span>` against two
returned rows.
The missing-`result` case still lands on the empty state, since `rows` is
`[]` there.
--
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]