SQLGen
Generate SQL from TableGen code - This is part of the tutorial "How to write a TableGen backend" in 2021 LLVM Developers' Meeting.
Install / Use
/learn @mshockwave/SQLGenREADME
SQLGen
Generate SQL from TableGen code
This is part of the tutorial "How to write a TableGen backend" in 2021 LLVM Developers' Meeting.
Prerequisites
This tool is build against LLVM of this particular Git SHA: 475de8da011c8ae79c453fa43593ec5b35f52962.
(Though I think using LLVM 13.0 release also works)
Build
Configuring CMake:
mkdir .build && cd .build
cmake -G Ninja -DLLVM_DIR=/path/to/llvm/install/lib/cmake/llvm ../
Then build:
ninja sqlgen
Example usage
Given the following TableGen file SampleQuery.td:
class Query <string table, dag query_fields = (all), dag condition = (none)> {
string TableName = table;
dag Fields = query_fields;
dag WhereClause = condition;
list<string> OrderedBy = [];
}
def : Query<"Orders", (fields "Person", "Amount")>;
We can use the following command to generate the corresponding SQL query:
$ .build/sqlgen SampleQuery.td -o SampleQuery.sql
$ cat SampleQuery.sql
SELECT Person, Amount FROM Orders;
$
Testing
SQLGen is using LLVM LIT as the testing harness. Please install it first:
pip3 install lit
SQLGen is also using the functionality of FileCheck. However, we support two variants of FileCheck:
- Using the
FileCheckcommand line tool from a LLVM build and put in your PATH. Note that unfortunately, LLVM doesn't shipFileCheckin their release tarball. - The recommended way: install the
filecheckpython package / command line tool viapip3 install filecheck.
After the lit is installed and FileCheck is setup, launch this command to run the tests:
cd .build
ninja check
Related Skills
oracle
339.5kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
prose
339.5kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
Command Development
83.9kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
Plugin Structure
83.9kThis skill should be used when the user asks to "create a plugin", "scaffold a plugin", "understand plugin structure", "organize plugin components", "set up plugin.json", "use ${CLAUDE_PLUGIN_ROOT}", "add commands/agents/skills/hooks", "configure auto-discovery", or needs guidance on plugin directory layout, manifest configuration, component organization, file naming conventions, or Claude Code plugin architecture best practices.
