diff --git a/pkg/ui/workspaces/cluster-ui/src/sqlActivity/util.tsx b/pkg/ui/workspaces/cluster-ui/src/sqlActivity/util.tsx index d770226c812a..748a13db2d61 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sqlActivity/util.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sqlActivity/util.tsx @@ -43,10 +43,18 @@ export function filteredStatementsData( // Current filters: search text, database, fullScan, service latency, // SQL Type, nodes and regions. return statements - .filter( - statement => - databases.length == 0 || databases.includes(statement.database), - ) + .filter(statement => { + try { + // Case where the database is returned as an array in a string form. + const dbList = JSON.parse(statement.database); + return ( + databases.length === 0 || databases.some(d => dbList.includes(d)) + ); + } catch (e) { + // Case where the database is a single value as a string. + return databases.length === 0 || databases.includes(statement.database); + } + }) .filter(statement => (filters.fullScan ? statement.fullScan : true)) .filter( statement => diff --git a/pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTable.tsx b/pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTable.tsx index f772d2e9f052..b7f4e111e006 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTable.tsx @@ -101,6 +101,16 @@ export function shortStatement( } } +function formatStringArray(databases: string): string { + try { + // Case where the database is returned as an array in a string form. + return JSON.parse(databases).join(", "); + } catch (e) { + // Case where the database is a single value as a string. + return databases; + } +} + export function makeStatementsColumns( statements: AggregateStatistics[], selectedApps: string[], @@ -173,7 +183,7 @@ export function makeStatementsColumns( name: "database", title: statisticsTableTitles.database(statType), className: cx("statements-table__col-database"), - cell: (stmt: AggregateStatistics) => stmt.database, + cell: (stmt: AggregateStatistics) => formatStringArray(stmt.database), sort: (stmt: AggregateStatistics) => stmt.database, showByDefault: false, },