Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

refactor: use uniqueBy helper in mergeIndexFields (#10106)

Kiran Gadhave00f506ee5655
diff --git a/frontend/src/components/data-table/charts/charts.tsx b/frontend/src/components/data-table/charts/charts.tsx
index ea1e349d20..545fa1481d 100644
--- a/frontend/src/components/data-table/charts/charts.tsx
+++ b/frontend/src/components/data-table/charts/charts.tsx
@@ -27,6 +27,7 @@ import { useDebouncedCallback } from "@/hooks/useDebounce";
import type { GetDataUrl } from "@/plugins/impl/DataTablePlugin";
import { vegaLoadData } from "@/plugins/impl/vega/loader";
import { useTheme } from "@/theme/useTheme";
+import { uniqueBy } from "@/utils/arrays";
import { inferFieldTypes } from "../columns";
import {
type FieldTypesWithExternalType,
@@ -67,9 +68,7 @@ export function mergeIndexFields(
if (!rowHeaders || rowHeaders.length === 0) {
return base;
}
- const seen = new Set(base.map(([name]) => name));
- const indexFields = rowHeaders.filter(([name]) => !seen.has(name));
- return [...base, ...indexFields];
+ return uniqueBy([...base, ...rowHeaders], (f) => f[0]);
}
export interface TablePanelProps {