{"id":23274400,"url":"https://github.com/systemxlabs/sqlparser-nom","last_synced_at":"2025-04-30T19:35:21.956Z","repository":{"id":194974385,"uuid":"691915102","full_name":"systemxlabs/sqlparser-nom","owner":"systemxlabs","description":"A SQL query parser written using nom.","archived":false,"fork":false,"pushed_at":"2024-07-10T01:38:29.000Z","size":176,"stargazers_count":75,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T19:21:47.740Z","etag":null,"topics":["database","logos","nom","parser","rust","sql"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/systemxlabs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-15T06:53:27.000Z","updated_at":"2025-03-23T16:31:08.000Z","dependencies_parsed_at":"2023-09-24T15:57:06.134Z","dependency_job_id":"5d397cc2-b585-42c6-8b0f-ec440d613a2e","html_url":"https://github.com/systemxlabs/sqlparser-nom","commit_stats":null,"previous_names":["systemxlabs/sqlparser-lalrpop","systemxlabs/sqlparser-nom"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemxlabs%2Fsqlparser-nom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemxlabs%2Fsqlparser-nom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemxlabs%2Fsqlparser-nom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemxlabs%2Fsqlparser-nom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/systemxlabs","download_url":"https://codeload.github.com/systemxlabs/sqlparser-nom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251769962,"owners_count":21641004,"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":["database","logos","nom","parser","rust","sql"],"created_at":"2024-12-19T20:13:07.722Z","updated_at":"2025-04-30T19:35:21.907Z","avatar_url":"https://github.com/systemxlabs.png","language":"Rust","readme":"# sqlparser-nom \nA SQL query parser written using nom.\n\n- [x] Query\n  - [x] Select\n  - [x] From\n  - [x] Where\n  - [x] Order by\n  - [x] Limit\n  - [x] CTE\n  - [x] Group by\n  - [x] Having\n  - [x] Aggregate\n  - [x] Window\n- [x] Pratt Parsing\n- [ ] Friendly error info\n\n## Example\nMore examples can be found in [tests](tests/query.rs).\n```sql\nselect a, count(*)\nfrom (select * from t1) as t2\njoin t3 on t2.a = t3.a\nleft join t4 on t3.b = t4.b\nwhere a \u003e ((1 + 2) * 3) and b \u003c c \ngroup by a, c \nhaving count(*) \u003e 5\norder by a, b desc \nlimit 1, 2\n```\noutput ast:\n```\nSelectStatement {\n    body: Select {\n        projection: [\n            UnnamedExpr(\n                ColumnRef {\n                    database: None,\n                    table: None,\n                    column: Ident {\n                        value: \"a\",\n                    },\n                },\n            ),\n            UnnamedExpr(\n                Function {\n                    name: Ident {\n                        value: \"count\",\n                    },\n                    distinct: false,\n                    args: [\n                        Wildcard,\n                    ],\n                },\n            ),\n        ],\n        from: Some(\n            Join {\n                op: LeftOuter,\n                condition: On(\n                    BinaryOp {\n                        left: ColumnRef {\n                            database: None,\n                            table: Some(\n                                Ident {\n                                    value: \"t3\",\n                                },\n                            ),\n                            column: Ident {\n                                value: \"b\",\n                            },\n                        },\n                        op: Eq,\n                        right: ColumnRef {\n                            database: None,\n                            table: Some(\n                                Ident {\n                                    value: \"t4\",\n                                },\n                            ),\n                            column: Ident {\n                                value: \"b\",\n                            },\n                        },\n                    },\n                ),\n                left: Join {\n                    op: Inner,\n                    condition: On(\n                        BinaryOp {\n                            left: ColumnRef {\n                                database: None,\n                                table: Some(\n                                    Ident {\n                                        value: \"t2\",\n                                    },\n                                ),\n                                column: Ident {\n                                    value: \"a\",\n                                },\n                            },\n                            op: Eq,\n                            right: ColumnRef {\n                                database: None,\n                                table: Some(\n                                    Ident {\n                                        value: \"t3\",\n                                    },\n                                ),\n                                column: Ident {\n                                    value: \"a\",\n                                },\n                            },\n                        },\n                    ),\n                    left: Subquery {\n                        subquery: SelectStatement {\n                            body: Select {\n                                projection: [\n                                    Wildcard,\n                                ],\n                                from: Some(\n                                    BaseTable {\n                                        name: TableName {\n                                            database: None,\n                                            table: Ident {\n                                                value: \"t1\",\n                                            },\n                                        },\n                                        alias: None,\n                                    },\n                                ),\n                                selection: None,\n                                group_by: [],\n                                having: None,\n                            },\n                            order_by: [],\n                            limit: None,\n                            offset: None,\n                        },\n                        alias: Some(\n                            Ident {\n                                value: \"t2\",\n                            },\n                        ),\n                    },\n                    right: BaseTable {\n                        name: TableName {\n                            database: None,\n                            table: Ident {\n                                value: \"t3\",\n                            },\n                        },\n                        alias: None,\n                    },\n                },\n                right: BaseTable {\n                    name: TableName {\n                        database: None,\n                        table: Ident {\n                            value: \"t4\",\n                        },\n                    },\n                    alias: None,\n                },\n            },\n        ),\n        selection: Some(\n            BinaryOp {\n                left: BinaryOp {\n                    left: ColumnRef {\n                        database: None,\n                        table: None,\n                        column: Ident {\n                            value: \"a\",\n                        },\n                    },\n                    op: Gt,\n                    right: BinaryOp {\n                        left: BinaryOp {\n                            left: Literal(\n                                UnsignedInteger(\n                                    1,\n                                ),\n                            ),\n                            op: Add,\n                            right: Literal(\n                                UnsignedInteger(\n                                    2,\n                                ),\n                            ),\n                        },\n                        op: Mul,\n                        right: Literal(\n                            UnsignedInteger(\n                                3,\n                            ),\n                        ),\n                    },\n                },\n                op: And,\n                right: BinaryOp {\n                    left: ColumnRef {\n                        database: None,\n                        table: None,\n                        column: Ident {\n                            value: \"b\",\n                        },\n                    },\n                    op: Lt,\n                    right: ColumnRef {\n                        database: None,\n                        table: None,\n                        column: Ident {\n                            value: \"c\",\n                        },\n                    },\n                },\n            },\n        ),\n        group_by: [\n            ColumnRef {\n                database: None,\n                table: None,\n                column: Ident {\n                    value: \"a\",\n                },\n            },\n            ColumnRef {\n                database: None,\n                table: None,\n                column: Ident {\n                    value: \"c\",\n                },\n            },\n        ],\n        having: Some(\n            BinaryOp {\n                left: Function {\n                    name: Ident {\n                        value: \"count\",\n                    },\n                    distinct: false,\n                    args: [\n                        Wildcard,\n                    ],\n                },\n                op: Gt,\n                right: Literal(\n                    UnsignedInteger(\n                        5,\n                    ),\n                ),\n            },\n        ),\n    },\n    order_by: [\n        OrderByExpr {\n            expr: ColumnRef {\n                database: None,\n                table: None,\n                column: Ident {\n                    value: \"a\",\n                },\n            },\n            asc: None,\n        },\n        OrderByExpr {\n            expr: ColumnRef {\n                database: None,\n                table: None,\n                column: Ident {\n                    value: \"b\",\n                },\n            },\n            asc: Some(\n                false,\n            ),\n        },\n    ],\n    limit: Some(\n        Literal(\n            UnsignedInteger(\n                1,\n            ),\n        ),\n    ),\n    offset: Some(\n        Literal(\n            UnsignedInteger(\n                2,\n            ),\n        ),\n    ),\n}\n```\n\n## References\n- [SQL92 Standard](https://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt)\n- [Antlr Grammars for SQL](https://github.com/antlr/grammars-v4/tree/master/sql)\n- [PostgreSQL Doc](https://www.postgresql.org/docs/16/sql.html)\n- [BNF Grammars for SQL-92, SQL-99 and SQL-2003](https://ronsavage.github.io/SQL/)\n- [Queries - Microsoft SQL Doc](https://learn.microsoft.com/en-us/sql/t-sql/queries/queries)\n- [Simple but Powerful Pratt Parsing](https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html)\n- [手写一个Parser - 代码简单而功能强大的Pratt Parsing](https://zhuanlan.zhihu.com/p/471075848)\n- [sqlparser-rs](https://github.com/sqlparser-rs/sqlparser-rs)\n- [databend](https://github.com/datafuselabs/databend/tree/main/src/query/ast)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemxlabs%2Fsqlparser-nom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsystemxlabs%2Fsqlparser-nom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemxlabs%2Fsqlparser-nom/lists"}