Registry / data / rhombic

rhombic

JSON →
library0.19.0jsnpmunverified

Rhombic is a SQL parsing, analysis, and manipulation library for TypeScript/JavaScript (v0.19.0). It provides two parsers: a Chevrotain-based parser for lightweight ANSI SQL manipulation (add projections, filters, ordering) and an Antlr-based parser (from Apache Spark SQL grammar) for broad dialect support and column-level lineage extraction. Rhombic ships TypeScript types, is actively maintained, and is designed for building SQL editors or data lineage tools. It differentiates from other SQL parsers (like sqlparser-js) by offering both manipulation and lineage in one package, with native TS support.

npm install rhombic
INSTALL
IMPORT
SIG · RHOMBIC
R
rhombic
datajavascriptv0.19.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

antlr
✓ import { antlr } from 'rhombic'
✗ const antlr = require('rhombic').antlr
ESM-only; named import for Antlr parser utilities.
TablePrimary
✓ import { TablePrimary } from 'rhombic'
✗ import TablePrimary from 'rhombic'
Type import for Antlr lineage; used as function parameter type.
rhombic (default import)
✓ import rhombic from 'rhombic'
✗ import { rhombic } from 'rhombic'
Default export for Chevrotain parser; common mistake is using curly braces.

Shows how to parse SQL with the Antlr parser and extract column-level lineage.

import { antlr, TablePrimary } from 'rhombic'; const parsingOptions = { doubleQuotedIdentifier: true }; const q = antlr.parse('SELECT * FROM abc;', parsingOptions); console.log(q.getUsedTables()); // [{ tableName: "abc" }] const getTable = (table: TablePrimary) => { // Logic to retrieve table & columns metadata return { columns: [] }; }; const mergedLeaves = true; const lineageOptions = { positionalRefsEnabled: false }; const lineage = q.getLineage(getTable, mergedLeaves, lineageOptions); console.log(lineage);
Debug
Known issues
gotchaTwo different parsers with different capabilities: Chevrotain for manipulation, Antlr for lineage. Using the wrong parser may lead to unsupported operations.
fix
Use `antlr.parse()` for lineage, and default import `rhombic.parse()` for manipulation.
affects: >=0.0.1
breakingESM-only package; does not support CommonJS require() directly.
fix
Use dynamic import() if in a CommonJS environment, or switch to ESM.
affects: >=0.19.0
deprecatedgetLineage API may change; positionaRefsEnabled option marked as experimental.
fix
Watch for version updates; check changelog.
affects: >=0.19.0
gotchaChevrotain parser (default import) only supports simple ANSI SQL statements; complex queries may fail to parse.
fix
Use Antlr parser for complex or dialect-specific SQL.
affects: >=0.0.1
gotchaLineage extraction requires a `getTable` callback that must return table metadata; failure to implement correctly may cause runtime errors.
fix
Ensure getTable returns an object with at least a `columns` array.
affects: >=0.0.1
Errors
Common errors & fixes
SyntaxError: Unexpected token, expected "," ...
Using Chevrotain parser on SQL not fully supported by its grammar (e.g., Hive, Spark SQL).
fix
Use antlr parser for non-ANSI SQL dialects.
TypeError: rhombic is not a function
Using named import instead of default import for Chevrotain parser.
fix
Use `import rhombic from 'rhombic'`.
Error: getTable is not a function
Second argument to getLineage must be a function that returns table metadata.
fix
Provide a function: `const getTable = (ref) => { return { columns: [] }; }`.
Upgrade
Version history
0.19.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
rhombic — npm install rhombic · libregistry