finds.dev← search

// the find

liyupi/sql-generator

★ 3,437 · Vue · Apache-2.0 · updated Jan 2024

🔨 用 JSON 来生成结构化的 SQL 语句,基于 Vue3 + TypeScript + Vite + Ant Design + MonacoEditor 实现,项目简单(重逻辑轻页面)、适合练手~

A browser-side tool that lets you write SQL as a JSON dictionary of named fragments, then assembles them via a macro-expansion engine — think C preprocessor but for SQL. Aimed at analysts and data engineers who write monster queries with repeated subquery patterns, especially in Hive/Spark environments where you can't use CTEs effectively.

The core idea is sound: named fragments with parameter passing eliminates the copy-paste death spiral that 3000-line analytical SQL creates. The recursive nested-call resolution (@a(xx = @b())) is the hard part and it's actually done correctly — the README calls out the greedy-regex trap they fixed. Monaco Editor integration is a good call for this use case; syntax highlighting and formatting matter when you're debugging macro expansion. The call tree visualization is genuinely useful for understanding what expands into what.

Last push was January 2024 and the project reads like a one-person learning exercise ('适合练手' — 'good for practice') that got popular, not a maintained tool. There's no test suite for the generator logic, which is the one piece that absolutely needs tests given the recursive substitution edge cases. The JSON-as-config approach falls apart with large queries because you lose editor support (no SQL autocomplete inside string values) and the parameter syntax (@xxx(a = 1 ||| b = 2)) is homebrew enough that anyone joining the project has to re-learn it. No export to CTE format, which is what most modern SQL engines actually want.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →