athena-client
raw JSON → 2.5.1 verified Sat Apr 25 auth: no javascript
athena-client is a simple Node.js and TypeScript client for AWS Athena, version 2.5.1. It wraps the AWS SDK to simplify query execution, supporting callbacks, Promises, and streams. Key features include configurable polling intervals, retry logic, concurrent execution limits, encryption options for S3 query results, and workgroup support. It is actively maintained with a stable API, but users must migrate from v1.x due to breaking changes. The package ships TypeScript definitions and is commonly used in Lambda functions.
Common errors
error TypeError: athena_client_1.default is not a function ↓
cause Incorrect default import syntax when the package exports named exports only.
fix
Use named imports: import { createClient } from 'athena-client';
error Cannot find module 'athena-client' ↓
cause Package not installed or import path misspelled.
fix
Run 'npm install athena-client' and verify package name in import.
error TimeoutError: Query execution timed out ↓
cause queryTimeout set too low or query takes longer than timeout value.
fix
Increase queryTimeout or ensure query completes within set time.
error Error: The bucket URI must be a valid S3 URI starting with 's3://' ↓
cause bucketUri missing or malformed.
fix
Set bucketUri to something like 's3://my-bucket/path/'
Warnings
breaking concurrentExecMax property in clientConfig is deprecated; use setConcurrentExecMax() instead. ↓
fix Replace concurrentExecMax in clientConfig with setConcurrentExecMax(max) call before creating client.
breaking Version 2.x has breaking changes from 1.x; callback and Promise APIs differ. ↓
fix Migrate from 1.x to 2.x by updating to the new API (e.g., client.execute().toPromise() instead of client.executePromise()).
deprecated concurrentExecMax clientConfig property is deprecated. ↓
fix Use setConcurrentExecMax() function.
gotcha bucketUri must be a valid S3 URI (e.g., s3://bucket/path/) and the bucket must allow Athena writes. ↓
fix Ensure the S3 bucket exists and has appropriate permissions for Athena.
gotcha Polling interval defaults to 1000ms; for faster queries, set a lower value. ↓
fix Adjust pollingInterval in clientConfig to suit query execution time.
Install
npm install athena-client yarn add athena-client pnpm add athena-client Imports
- athenaClient wrong
import athenaClient from 'athena-client';correctimport { createClient, setConcurrentExecMax } from 'athena-client'; - createClient wrong
const { createClient } = require('athena-client');correctimport { createClient } from 'athena-client'; - concurrentExecMax
import { setConcurrentExecMax } from 'athena-client';
Quickstart
import { createClient, setConcurrentExecMax } from 'athena-client';
setConcurrentExecMax(3);
const client = createClient(
{
bucketUri: process.env.BUCKET_URI ?? 's3://my-athena-results',
database: 'mydb',
pollingInterval: 500,
workGroup: 'primary',
},
{
region: process.env.AWS_REGION ?? 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '',
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? '',
}
);
async function run() {
try {
const data = await client.execute('SELECT 1').toPromise();
console.log(data);
} catch (err) {
console.error(err);
}
}
run();