{"id":19427794,"url":"https://github.com/starrocks/sqltransformer","last_synced_at":"2026-04-07T04:31:32.415Z","repository":{"id":230880346,"uuid":"777179274","full_name":"StarRocks/SQLTransformer","owner":"StarRocks","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-28T02:25:25.000Z","size":294,"stargazers_count":22,"open_issues_count":1,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-04-01T09:31:51.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StarRocks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-03-25T11:08:33.000Z","updated_at":"2026-03-28T06:57:04.000Z","dependencies_parsed_at":"2024-04-01T10:59:17.263Z","dependency_job_id":null,"html_url":"https://github.com/StarRocks/SQLTransformer","commit_stats":null,"previous_names":["starrocks/sqltransformer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/StarRocks/SQLTransformer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarRocks%2FSQLTransformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarRocks%2FSQLTransformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarRocks%2FSQLTransformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarRocks%2FSQLTransformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StarRocks","download_url":"https://codeload.github.com/StarRocks/SQLTransformer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarRocks%2FSQLTransformer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31500397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-10T14:12:55.696Z","updated_at":"2026-04-07T04:31:32.401Z","avatar_url":"https://github.com/StarRocks.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ClickHouse SQL Rewriter\n# Introduction\nThe ClickHouse SQL Rewriter provides the ability to convert ClickHouse SQL queries into StarRocks/Doris SQL queries. It offers several features to facilitate this conversion:\n\n1. Function Rewrite:\n   * The most commonly used ClickHouse functions are automatically rewritten to their syntactically equivalent counterparts in StarRocks.\n   * Overload resolution: For overloaded functions in ClickHouse, the rewriter supports global field type reference for resolution. Users can also provide optional table-level field type information for better resolution. For example, the toDateTime function can parse either a Unix timestamp (e.g., `1711405674`) or a string with a datetime pattern (e.g., `2024-01-01 00:00:00`).\n2. Scoped Calculated Column:\n   * ClickHouse supports ad hoc calculated columns for reuse within the same level. The ClickHouse SQL Rewriter also supports this feature.\n3. Ambiguous Column Resolution:\n   * ClickHouse allows users to omit the subquery label of a column, even if it appears in both the left and right parts of a join. For example, `select c from (select c from a) t1 left join (select c from b) t2` is allowed in ClickHouse but would cause an error (`c is ambiguous`). The ClickHouse SQL Rewriter can rewrite `c` to `t1.c`, resolving the ambiguity.\n4. Automatic Subquery Alias:\n   * Similar to ambiguous columns, ClickHouse allows subqueries without aliases. The ClickHouse SQL Rewriter automatically assigns labels to subqueries without aliases.\n5. Complex Syntax Rewrite:\n   * Window clause: ClickHouse allows users to specify a window clause using the syntax window `\u003cwindow_name\u003e as (partition by \u003ccolumn\u003e`).\n   * Array Join Clause: ClickHouse supports specifying an array join clause.\n   * Double Quote Strip: In ClickHouse, double quotes are used to quote identifiers, while in StarRocks and most other SQL dialects, they are used for strings. The ClickHouse SQL Rewriter handles the necessary conversions.\n6. More:\n   * The `BaseSqlBuilder` template allows easy conversion of ClickHouse SQL to any desired SQL dialect. Simply subclass `BaseSqlBuilder` and start using it.\n\n# Quick Start\n```java\nString clickhouseSql = \"SELECT toDateTime(date_time) FROM db.table\";\nStarRocksSqlBuilder sr = new StarRocksSqlBuilder();\nString starRocksSql = sr.getStarRocksSql(clickhouseSql);\nSystem.out.println(starRocksSql);\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarrocks%2Fsqltransformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarrocks%2Fsqltransformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarrocks%2Fsqltransformer/lists"}