Replace node-sql-parser with sqlparser-ts#61111
Replace node-sql-parser with sqlparser-ts#61111guan404ming wants to merge 1 commit intoapache:mainfrom
Conversation
fd75111 to
63e11de
Compare
63e11de to
3aabf11
Compare
pierrejeambrun
left a comment
There was a problem hiding this comment.
Thanks @guan404ming for this proposal, indeed such optimization would be a good addition I believe.
I don't feel super confident adding a third party dependency freshly created and that hasn't a track record of 'working' in production. (and being popular amongst the community).
Do you know if there are more popular alternatives? If there is not what would it take to directly embed datafusion-sqlparser-rs within airflow without relying on an external package?
Just exploring our options here.
|
Thanks for the feedback! Totally valid concern regarding the new dependency.
Here is some alternatives but most of them are either support specific dialects or lack of maintenance. After this investigation, I then decide to start to build by myself.
I've also consider this option before. But since the core logic of
Technically, I think the package is robust. I’ve ported the test suite directly from the upstream Rust repo to typescript to ensure the behavior matches the source of truth 1:1. On top of that, I’ve included comprehensive unit tests in this PR to guarantee it integrates with the Airflow UI without causing regressions. I completely understand the hesitation with relying on a fresh personal repo. I will continue promoting this package to other projects to build a stronger track record. My ideal target is try to donate and transfer this package to the Apache Datafusion upstream. This would make it into an community-governed artifact, removing the dependency on a single individual. However I hope we can still keep this conversation open. I’d really appreciate it if you could give the pkg a spin to see the value. Thanks! |
481ca78 to
206a3fb
Compare
206a3fb to
49d1485
Compare

TL;DR
Replaced node-sql-parser with sqlparser-ts
This new one is 14x smaller, 5x faster and is a library I actively maintain.
Why
node-sql-parseradds a massive ~88 MB footprint to the package just to handle SQL string detection.How
sqlparser-ts, a library I develop and maintain, which brings the power of Rust’s sqlparser from Apache DataFusion to JS/TS via WebAssembly. It offers superior performance with zero JS/TS dependencies.detectLanguage.tsto usesqlparser-ts'svalidate()function instead ofnode-sql-parser'sparse()for SQL detectionBenchmark
This optimization slashed the package size by 93% and boosted validation speed by 5.4x, while delivering superior SQL compatibility and maintaining stable load times compare to pure js implementation.
More detailed benchmark between
sqlparser-tsandnode-sql-parser--> https://github.com/guan404ming/sqlparser-ts/tree/main/benchmarkBundle Analyzer Treemap
before
after
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code with Opus 4.5 following the guidelines
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.