{"id":28724097,"url":"https://github.com/mshockwave/sqlgen","last_synced_at":"2025-06-15T10:09:15.969Z","repository":{"id":62834469,"uuid":"420534175","full_name":"mshockwave/SQLGen","owner":"mshockwave","description":"Generate SQL from TableGen code - This is part of the tutorial \"How to write a TableGen backend\" in 2021 LLVM Developers' Meeting.","archived":false,"fork":false,"pushed_at":"2023-02-18T12:49:01.000Z","size":23,"stargazers_count":23,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-23T17:24:53.573Z","etag":null,"topics":["compiler","llvm","sql"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mshockwave.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-23T22:14:08.000Z","updated_at":"2024-03-06T12:24:02.000Z","dependencies_parsed_at":"2022-11-07T16:00:48.639Z","dependency_job_id":null,"html_url":"https://github.com/mshockwave/SQLGen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mshockwave/SQLGen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mshockwave%2FSQLGen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mshockwave%2FSQLGen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mshockwave%2FSQLGen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mshockwave%2FSQLGen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mshockwave","download_url":"https://codeload.github.com/mshockwave/SQLGen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mshockwave%2FSQLGen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259957282,"owners_count":22937549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","llvm","sql"],"created_at":"2025-06-15T10:09:14.929Z","updated_at":"2025-06-15T10:09:15.951Z","avatar_url":"https://github.com/mshockwave.png","language":"C++","readme":"# SQLGen\n## Generate SQL from TableGen code\nThis is part of the tutorial _\"How to write a TableGen backend\"_ in 2021 LLVM Developers' Meeting.\n\n## Prerequisites\nThis tool is build against LLVM of this particular Git SHA: `475de8da011c8ae79c453fa43593ec5b35f52962`.\n(Though I think using LLVM 13.0 release also works)\n\n## Build\nConfiguring CMake:\n```bash\nmkdir .build \u0026\u0026 cd .build\ncmake -G Ninja -DLLVM_DIR=/path/to/llvm/install/lib/cmake/llvm ../\n```\nThen build:\n```bash\nninja sqlgen\n```\n\n## Example usage\nGiven the following TableGen file `SampleQuery.td`:\n```tblgen\nclass Query \u003cstring table, dag query_fields = (all), dag condition = (none)\u003e {\n  string TableName = table;\n  dag Fields = query_fields;\n  dag WhereClause = condition;\n  list\u003cstring\u003e OrderedBy = [];\n}\n\ndef : Query\u003c\"Orders\", (fields \"Person\", \"Amount\")\u003e;\n```\nWe can use the following command to generate the corresponding SQL query:\n```bash\n$ .build/sqlgen SampleQuery.td -o SampleQuery.sql\n$ cat SampleQuery.sql\nSELECT Person, Amount FROM Orders;\n$\n```\n\n## Testing\nSQLGen is using [LLVM LIT](https://pypi.org/project/lit) as the testing harness. Please install it first:\n```bash\npip3 install lit\n```\nSQLGen is also using the functionality of [FileCheck](https://llvm.org/docs/CommandGuide/FileCheck.html).\nHowever, we support two variants of FileCheck:\n 1. Using the `FileCheck` command line tool from a LLVM build and put in your PATH. Note that unfortunately, LLVM doesn't ship `FileCheck` in their release tarball.\n 2. The recommended way: install the `filecheck` [python package / command line tool](https://github.com/mull-project/FileCheck.py) via `pip3 install filecheck`.\n\nAfter the `lit` is installed and FileCheck is setup, launch this command to run the tests:\n```bash\ncd .build\nninja check\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmshockwave%2Fsqlgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmshockwave%2Fsqlgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmshockwave%2Fsqlgen/lists"}