{"id":43771,"library":"rhombic","title":"Rhombic","description":"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.","status":"active","version":"0.19.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","sql","calcite","ast","helpers","parser","apache","typescript"],"install":[{"cmd":"npm install rhombic","lang":"bash","label":"npm"},{"cmd":"yarn add rhombic","lang":"bash","label":"yarn"},{"cmd":"pnpm add rhombic","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; named import for Antlr parser utilities.","wrong":"const antlr = require('rhombic').antlr","symbol":"antlr","correct":"import { antlr } from 'rhombic'"},{"note":"Type import for Antlr lineage; used as function parameter type.","wrong":"import TablePrimary from 'rhombic'","symbol":"TablePrimary","correct":"import { TablePrimary } from 'rhombic'"},{"note":"Default export for Chevrotain parser; common mistake is using curly braces.","wrong":"import { rhombic } from 'rhombic'","symbol":"rhombic (default import)","correct":"import rhombic from 'rhombic'"}],"quickstart":{"code":"import { antlr, TablePrimary } from 'rhombic';\n\nconst parsingOptions = {\n  doubleQuotedIdentifier: true\n};\nconst q = antlr.parse('SELECT * FROM abc;', parsingOptions);\nconsole.log(q.getUsedTables()); // [{ tableName: \"abc\" }]\n\nconst getTable = (table: TablePrimary) => {\n  // Logic to retrieve table & columns metadata\n  return { columns: [] };\n};\nconst mergedLeaves = true;\nconst lineageOptions = { positionalRefsEnabled: false };\nconst lineage = q.getLineage(getTable, mergedLeaves, lineageOptions);\nconsole.log(lineage);","lang":"typescript","description":"Shows how to parse SQL with the Antlr parser and extract column-level lineage."},"warnings":[{"fix":"Use `antlr.parse()` for lineage, and default import `rhombic.parse()` for manipulation.","message":"Two different parsers with different capabilities: Chevrotain for manipulation, Antlr for lineage. Using the wrong parser may lead to unsupported operations.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use dynamic import() if in a CommonJS environment, or switch to ESM.","message":"ESM-only package; does not support CommonJS require() directly.","severity":"breaking","affected_versions":">=0.19.0"},{"fix":"Watch for version updates; check changelog.","message":"getLineage API may change; positionaRefsEnabled option marked as experimental.","severity":"deprecated","affected_versions":">=0.19.0"},{"fix":"Use Antlr parser for complex or dialect-specific SQL.","message":"Chevrotain parser (default import) only supports simple ANSI SQL statements; complex queries may fail to parse.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Ensure getTable returns an object with at least a `columns` array.","message":"Lineage extraction requires a `getTable` callback that must return table metadata; failure to implement correctly may cause runtime errors.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"search_vec":"'activ':58 'add':28 'analysi':7 'ansi':25 'antlr':35 'antlr-bas':34 'apach':39,100 'ast':97 'base':21,36 'broad':44 'build':64 'calcit':96 'chevrotain':20 'chevrotain-bas':19 'column':49 'column-level':48 'data':68 'design':62 'dialect':45 'differenti':72 'editor':66 'extract':52 'filter':30 'grammar':42 'helper':98 'javascript':94 'js':80 'level':50 'librari':10 'lightweight':24 'like':77 'lineag':51,69,86 'maintain':59 'manipul':9,27,84 'nativ':91 'offer':82 'one':88 'order':31 'packag':89 'pars':6 'parser':17,22,37,76,99 'project':29 'provid':15 'rhombic':1,2,53 'ship':54 'spark':40 'sql':5,26,41,65,75,95 'sqlparser':79 'sqlparser-j':78 'support':46,93 'tool':70 'ts':92 'two':16 'type':56 'typescript':55,101 'typescript/javascript':12 'v0.19.0':13","created_at":"2026-06-05T17:01:24.204440+00:00","updated_at":"2026-06-05T17:01:24.204440+00:00","problems":[{"fix":"Use antlr parser for non-ANSI SQL dialects.","cause":"Using Chevrotain parser on SQL not fully supported by its grammar (e.g., Hive, Spark SQL).","error":"SyntaxError: Unexpected token, expected \",\" ..."},{"fix":"Use `import rhombic from 'rhombic'`.","cause":"Using named import instead of default import for Chevrotain parser.","error":"TypeError: rhombic is not a function"},{"fix":"Provide a function: `const getTable = (ref) => { return { columns: [] }; }`.","cause":"Second argument to getLineage must be a function that returns table metadata.","error":"Error: getTable is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"rhombic","openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}