diff --git a/ui/src/frontend/sql_table_tab.ts b/ui/src/frontend/sql_table_tab.ts index 325c95c737..85c9d30882 100644 --- a/ui/src/frontend/sql_table_tab.ts +++ b/ui/src/frontend/sql_table_tab.ts @@ -84,6 +84,9 @@ export class SqlTableTab extends BottomTab { }), ]; const {selectStatement, columns} = this.state.getCurrentRequest(); + const debugTrackColumns = Object.values(columns).filter( + (c) => !c.startsWith('__'), + ); const addDebugTrack = m( Popup, { @@ -92,8 +95,8 @@ export class SqlTableTab extends BottomTab { }, m(AddDebugTrackMenu, { dataSource: { - sqlSource: selectStatement, - columns: Object.values(columns).filter((c) => !c.startsWith('__')), + sqlSource: `SELECT ${debugTrackColumns.join(', ')} FROM (${selectStatement})`, + columns: debugTrackColumns, }, engine: this.engine, }),