EnxDev commented on code in PR #37396:
URL: https://github.com/apache/superset/pull/37396#discussion_r3195304800
##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -315,9 +350,10 @@ export const useTableColumns = (
? colnames
.filter((column: string) => Object.keys(data[0]).includes(column))
.map((key, index) => {
- const colType = coltypes?.[index];
+ const originalIndex = (colnames || []).indexOf(key);
+ const colType = coltypes?.[originalIndex];
+ const colLabel = collabels?.[originalIndex];
const firstValue = data[0][key];
- const headerLabel = columnDisplayNames?.[key] ?? key;
const originalFormattedTimeColumnIndex =
colType === GenericDataType.Temporal
? originalFormattedTimeColumns.indexOf(key)
Review Comment:
The filter() only ever drops columns missing from data[0] if colnames
contains duplicates (it shouldn't, but the type doesn't forbid it), indexOf
always returns the first match.
A Map<string, number> built once outside the .map would also be O(n) instead
of O(n²).
--
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]