diff --git a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx index a67b5e2640b83..3d17e0fd8163b 100644 --- a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx +++ b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx @@ -155,6 +155,7 @@ const ROWS_CHIP_WIDTH = 100; const GAP = 8; const extensionsRegistry = getExtensionsRegistry(); +const EMPTY: string[] = []; const ResultSet = ({ cache = false, @@ -213,6 +214,10 @@ const ResultSet = ({ () => query.results?.columns.map(col => col.column_name), [query.results?.columns], ); + const expandedColumns = useMemo( + () => query.results?.expanded_columns.map(col => col.column_name) ?? EMPTY, + [query.results?.expanded_columns], + ); const history = useHistory(); const dispatch = useDispatch(); @@ -646,9 +651,6 @@ const ResultSet = ({ ({ data } = results); } if (data && data.length > 0) { - const expandedColumns = results.expanded_columns - ? results.expanded_columns.map(col => col.column_name) - : []; const allowHTML = getItem( LocalStorageKeys.SqllabIsRenderHtmlEnabled, true,