Skip to content

Commit

Permalink
Fix viewing tables in connections browser
Browse files Browse the repository at this point in the history
Currently trying to expand tables in the connections browser results in an error:
```
Request connection/GetChildrenForTreeItemRequest failed with message: Cannot read properties of undefined (reading 'ResultSet')
```

This happens because `SHOW TABLES` and `SHOW VIEWS` do not return data as regular queries.
Instead it has to be pulled as a separate request.

This fixes kovihq#41
  • Loading branch information
Aleksei-Poliakov authored Apr 4, 2024
1 parent 0a5f2fe commit d6b369d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ls/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,12 @@ export default class AthenaDriver extends AbstractDriver<Athena, Athena.Types.Cl
const tables = await this.rawQuery(`SHOW TABLES IN \`${parent.database}\``);
const views = await this.rawQuery(`SHOW VIEWS IN "${parent.database}"`);

const viewsSet = new Set(views[0].ResultSet.Rows.map((row) => row.Data[0].VarCharValue));
const tablesResult = await this.getQueryResults(tables.QueryExecution.QueryExecutionId);
const viewsResult = await this.getQueryResults(views.QueryExecution.QueryExecutionId);

return tables[0].ResultSet.Rows
const viewsSet = new Set(viewsResult[0].ResultSet.Rows.map((row) => row.Data[0].VarCharValue));

return tablesResult[0].ResultSet.Rows
.filter((row) => !viewsSet.has(row.Data[0].VarCharValue))
.map((row) => ({
database: parent.database,
Expand Down

0 comments on commit d6b369d

Please sign in to comment.