{"id":17570570,"url":"https://github.com/AfterShip/clickhouse-sql-parser","last_synced_at":"2025-03-07T21:30:44.623Z","repository":{"id":196217212,"uuid":"694946961","full_name":"AfterShip/clickhouse-sql-parser","owner":"AfterShip","description":"ClickHouse SQL Parser writing in Go","archived":false,"fork":false,"pushed_at":"2024-10-23T04:02:04.000Z","size":614,"stargazers_count":141,"open_issues_count":3,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-24T18:52:28.303Z","etag":null,"topics":["clickhouse","go","sql-parser"],"latest_commit_sha":null,"homepage":"","language":"Go","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/AfterShip.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-22T02:56:16.000Z","updated_at":"2024-10-23T17:59:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"98d554b5-61aa-4312-b7b6-b5d542403c8c","html_url":"https://github.com/AfterShip/clickhouse-sql-parser","commit_stats":null,"previous_names":["aftership/clickhouse-sql-parser"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AfterShip%2Fclickhouse-sql-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AfterShip%2Fclickhouse-sql-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AfterShip%2Fclickhouse-sql-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AfterShip%2Fclickhouse-sql-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AfterShip","download_url":"https://codeload.github.com/AfterShip/clickhouse-sql-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242467161,"owners_count":20133105,"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":["clickhouse","go","sql-parser"],"created_at":"2024-10-21T18:01:14.912Z","updated_at":"2025-03-07T21:30:44.617Z","avatar_url":"https://github.com/AfterShip.png","language":"Go","readme":"# ClickHouse SQL Parser \n![GitHub CI](https://github.com/AfterShip/clickhouse-sql-parser/actions/workflows/ci.yaml/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/AfterShip/clickhouse-sql-parser)](https://goreportcard.com/report/github.com/AfterShip/clickhouse-sql-parser) [![LICENSE](https://img.shields.io/github/license/AfterShip/clickhouse-sql-parser.svg)](https://github.com/AfterShip/clickhouse-sql-parser/blob/master/LICENSE) [![GoDoc](https://img.shields.io/badge/Godoc-reference-blue.svg)](https://godoc.org/github.com/AfterShip/clickhouse-sql-parser) [![Coverage Status](https://coveralls.io/repos/github/AfterShip/clickhouse-sql-parser/badge.svg?branch=master)](https://coveralls.io/github/AfterShip/clickhouse-sql-parser?branch=master) \u003ca href=\"https://hellogithub.com/repository/23597949cafa410bba6039ddb8867543\" target=\"_blank\"\u003e\u003cimg src=\"https://api.hellogithub.com/v1/widgets/recommend.svg?rid=23597949cafa410bba6039ddb8867543\u0026claim_uid=kyCYu1VAKgwD8rE\u0026theme=small\" alt=\"Featured｜HelloGitHub\" /\u003e\u003c/a\u003e\n\nThe goal of this project is to build a ClickHouse SQL parser in Go with the following key features:\n\n- Parse ClickHouse SQL into AST\n- Beautify ClickHouse SQL format\n\nThis project is inspired by [memefish](https://github.com/cloudspannerecosystem/memefish) which is a SQL parser for Spanner in Go.\n## How to use\n\nYou can use it as your Go library or CLI tool, see the following examples:\n\n- Use clickhouse-sql-parser as a Go library\n\n```Go\npackage main\n\nimport (\n    clickhouse \"github.com/AfterShip/clickhouse-sql-parser/parser\"\n)\n\nquery := \"SELECT * FROM clickhouse\"\nparser := clickhouse.NewParser(query)\n// Parse query into AST\nstatements, err := parser.ParseStmts()\nif err != nil {\n    return nil, err\n}\n```\n\n- Install clickhouse-sql-parser as a CLI tool\n\n\nOn Linux:\n\n```bash\n$ go install github.com/AfterShip/clickhouse-sql-parser@latest\n```\n\nOn macOS:\n\n```bash\n$ brew install clickhouse-sql-parser\n```\n\nParse ClickHouse SQL into AST or beautify ClickHouse SQL format:\n\n```bash\n## Parse query into AST\n$ clickhouse-sql-parser \"SELECT * FROM clickhouse WHERE a=100\"\n\n## Beautify query\n$ clickhouse-sql-parser -format \"SELECT * FROM clickhouse WHERE a=100\"\n\n## Parse query from file\n$ clickhouse-sql-parser -file ./test.sql\n```\n\n- Parsed tree(AST) back into a SQL statement\n\n```Go\nparser := clickhouse.NewParser(\"SELECT * FROM clickhouse\")\n// Parse query into AST\nstatements, err := parser.ParseStmts()\nif err != nil {\n    return nil, err\n}\n\n// Call the String method to unparsed AST into a SQL string\nfor _, stmt := range statements {\n  fmt.Println(stmt.String())\n}\n```\n## Update test assets\n\nFor the files inside `output` and `format` dir are generated by the test cases,\n\nif you want to update them, you can run the following command:\n\n```bash\n$ make update_test\n```\n\n## Contact us\n\nFeel free to open an issue or discussion if you have any issues or questions.\n","funding_links":[],"categories":["Language bindings","Go"],"sub_categories":["Golang"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAfterShip%2Fclickhouse-sql-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAfterShip%2Fclickhouse-sql-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAfterShip%2Fclickhouse-sql-parser/lists"}