npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

athena-query-builder

v0.1.3

Published

Fluent, immutable SQL builder for AWS Athena (Presto/Trino-style SQL). Phase 1 focuses on single-table SELECT generation with escaped string literals—no query execution, catalog access, or ORM.

Readme

Athena Query Builder

npm version license Node.js

Fluent, immutable SQL builder for AWS Athena (Presto/Trino-style SQL). Phase 1 focuses on single-table SELECT generation with escaped string literals—no query execution, catalog access, or ORM.

Features

  • Fluent chain API — Knex/Lucid-style method chaining; each call returns a new immutable instance
  • Single-table SELECTselect, from, whereEq, whereIn, orderBy, limit
  • Safe literals — String values are escaped and embedded via QuoteString / FormatScalar (no bind parameters)
  • whereIn empty array — Renders 1=0 (always false) instead of invalid IN ()
  • Identifier validation — Unquoted names limited to alphanumeric, dot, and underscore (Phase 1)
  • TypeScript — Strict types for columns, sort direction, and scalar values
  • UtilitiesQuoteString, AssertIdentifier, and FormatScalar classes under utils/ for reuse

Installation

npm

npm install athena-query-builder

yarn

yarn add athena-query-builder

Usage

import { AthenaQueryBuilder } from 'athena-query-builder';

const exampleKeys = ['ex-1', 'ex-2'];

const sql = new AthenaQueryBuilder()
  .select(['example_id', { column: 'example_value', as: 'v' }])
  .from('example_table')
  .whereIn('example_key', exampleKeys)
  .whereEq('example_status', 'active')
  .orderBy('example_id', 'asc')
  .limit(1000)
  .toSql();

console.log(sql);

Example output:

SELECT example_id, example_value AS v
FROM example_table
WHERE example_key IN ('ex-1', 'ex-2') AND example_status = 'active'
ORDER BY example_id ASC
LIMIT 1000

Immutable branching

Reuse a base builder and branch without side effects:

const base = new AthenaQueryBuilder()
  .select(['example_id'])
  .from('example_table');

const forKeyA = base.whereIn('example_key', ['ex-a']);
const forKeyB = base.whereIn('example_key', ['ex-b']);

SQL formatting utilities

import { QuoteString, AssertIdentifier, FormatScalar } from 'athena-query-builder';

new QuoteString().execute("it's");              // "'it''s'"
new AssertIdentifier().execute('example_table'); // 'example_table'
new FormatScalar().execute(42);                  // '42'

Options

AthenaQueryBuilder

| Method | Description | |--------|-------------| | select(columns) | SELECT list. Each entry is a column name or { column, as? }. | | from(table) | Single table name (validated identifier). | | whereEq(column, value) | column = literal or column IS NULL when value is null. | | whereIn(column, values) | column IN (...); empty values1=0. | | orderBy(column, direction) | Append one ORDER BY entry ('asc' | 'desc'). | | orderBy(entries) | Append multiple { column, direction } entries. | | limit(n) | LIMIT n (n must be a non-negative integer). | | toSql() | Build the final SQL string (newline-separated clauses). | | build() | Alias for toSql(). |

toSql() requires both select() and from() to have been called.

Scalar types (WhereScalar)

string | number | boolean | null

Out of scope (Phase 1)

  • JOIN, WITH, subquery FROM, GROUP BY, HAVING, window functions
  • StartQueryExecution, result polling, Glue catalog APIs
  • Environment variable reads or query-plan optimization

Requirements

  • Node.js >= 20.0.0

License

This project is licensed under the Apache-2.0 License.