Skip to content

Commit

Permalink
test connection fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
stepinfwd committed Jun 14, 2022
1 parent f87f0d6 commit 2cc2234
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions plugins/packages/athena/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ export default class Athena implements QueryService {
}

async testConnection(sourceOptions: SourceOptions): Promise<ConnectionTestResult> {
const AthenaExpress = require('athena-express'),
AWS = require('aws-sdk'),
awsCredentials = {
region: sourceOptions.region,
accessKeyId: sourceOptions.access_key,
secretAccessKey: sourceOptions.secret_key,
};

AWS.config.update(awsCredentials);

const athenaExpressConfig = {
aws: AWS,
getStats: true,
db: sourceOptions.database,
};

const athenaExpress = new AthenaExpress(athenaExpressConfig);
try {
await athenaExpress.query('SHOW TABLES');
} catch (error) {
throw new Error(error);
}
return {
status: 'ok',
};
Expand Down

0 comments on commit 2cc2234

Please sign in to comment.