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

bq-dt-sql-parser

v4.1.0

Published

SQL Parsers for BigData, built with antlr4

Downloads

40

Readme

dt-sql-parser

English | 简体中文

dt-sql-parser is a SQL Parser project built with ANTLR4, and it's mainly for the BigData field. The ANTLR4 generated the basic Parser, Visitor, and Listener, so it's easy to complete the Lexer, Parser, traverse the AST, and so on features.

Additionally, it provides advanced features such as SQL Validation, Code Completion, and Collecting Table and Columns in SQL.

Supported SQL Dialects

  • MySQL
  • Flink
  • Spark (including Recursive Queries)
  • Hive
  • PostgreSQL
  • Trino
  • Impala

[!TIP] This project is the default for the TypeScript target, but you can also try to compile it to other languages if needed.

New in this Version

  • Recursive Queries Support for SparkSQL: We have updated SparkSqlParser.ts to include support for recursive queries, allowing better parsing and analysis of complex queries in Spark.

Installation

# use npm
npm i dt-sql-parser --save

# use yarn
yarn add dt-sql-parser

Usage

We recommend learning the fundamentals before continuing. The dt-sql-parser library provides SQL classes for different types of SQL.

import { MySQL, FlinkSQL, SparkSQL, HiveSQL, PostgreSQL, TrinoSQL, ImpalaSQL } from 'dt-sql-parser';

Before using syntax validation, code completion, and other features, it is necessary to instantiate the parser for the relevant SQL type. For instance, one can consider using MySQL as an example:

const mysql = new MySQL();

The following usage examples will utilize MySQL, but the parser for other SQL types works similarly.

Syntax Validation

import { MySQL } from 'dt-sql-parser';

const mysql = new MySQL();
const incorrectSql = 'selec id,name from user1;';
const errors = mysql.validate(incorrectSql);

console.log(errors);

Recursive Queries in SparkSQL

Now, dt-sql-parser supports Recursive Queries in SparkSQL, allowing better handling of queries using WITH RECURSIVE.

import { SparkSQL } from 'dt-sql-parser';

const spark = new SparkSQL();
const recursiveQuery = `
    WITH RECURSIVE employee_hierarchy AS (
        SELECT id, manager_id, name FROM employees WHERE manager_id IS NULL
        UNION ALL
        SELECT e.id, e.manager_id, e.name FROM employees e
        INNER JOIN employee_hierarchy eh ON e.manager_id = eh.id
    )
    SELECT * FROM employee_hierarchy;
`;

const errors = spark.validate(recursiveQuery);
console.log(errors.length === 0 ? "Valid SQL" : errors);

For more examples and features, check the documentation.