{"id":18336022,"url":"https://github.com/zicat/coron","last_synced_at":"2025-04-09T19:52:33.043Z","repository":{"id":166238852,"uuid":"448493636","full_name":"zicat/coron","owner":"zicat","description":"Coron is a tool to find the max-public sub node on sql list, rewrite sql.","archived":false,"fork":false,"pushed_at":"2022-01-16T08:08:42.000Z","size":901,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T12:17:58.747Z","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/zicat.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,"publiccode":null,"codemeta":null}},"created_at":"2022-01-16T08:06:44.000Z","updated_at":"2022-01-16T10:28:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"08014ea4-1d8b-4cee-af0a-4e15c352228b","html_url":"https://github.com/zicat/coron","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zicat%2Fcoron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zicat%2Fcoron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zicat%2Fcoron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zicat%2Fcoron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zicat","download_url":"https://codeload.github.com/zicat/coron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103905,"owners_count":21048244,"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":[],"created_at":"2024-11-05T20:05:34.626Z","updated_at":"2025-04-09T19:52:33.019Z","avatar_url":"https://github.com/zicat.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduce Coron\nCoron is a tool to find the max-public sub tree on query list, and create the calcite materialized view query automatically. \n# Introduce sub modules\n## coron-parser\nProvide CalciteContext to convert sql to RelNode conveniently. \n\n## coron-core\nFind the max-public sub tree on two RelNodes.\n\n## coron-analyzer\nCheck max-public sub tree whether can convert materialized view query and replace the query, filter useless sub tree \n\n# Example\n-  Compile and Install Project\n   ```shell\n   $ git clone https://github.com/zicat/coron.git\n   $ cd coron \u0026\u0026 maven clean install\n    ```\n-  Import dependency by maven like below\n    ```xml\n    \u003cdependency\u003e\n        \u003cartifactId\u003ecoron-analyzer\u003c/artifactId\u003e\n        \u003cgroupId\u003eorg.zicat\u003c/groupId\u003e\n        \u003cversion\u003e1.0-SNAPSHOT\u003c/version\u003e\n    \u003c/dependency\u003e\n    ```\n- Java code example\n    ```java\n    public static void main(String[] args) throws SqlParseException {\n        //create context and register table meta.\n        final String ddl = \"CREATE TABLE default_db.test(d1 varchar, d2 varchar, m1 int, m2 bigint)\";\n        final CalciteContext context = new CalciteContext(\"default_db\").addTables(ddl);\n\n        // convert sql query to relNode.\n        final String query1 = \"SELECT d1, sum(m1) AS s1 FROM default_db.test WHERE d1 = 'aaa' GROUP BY d1\";\n        final String query2 = \"SELECT d1, sum(m2) AS s2 FROM default_db.test WHERE d1 = 'bbb' GROUP BY d1\";\n        final RelNode relNode1 = context.querySql2Rel(query1);\n        final RelNode relNode2 = context.querySql2Rel(query2);\n\n        //find the public sub sql and print\n        final ResultNode\u003cRelNode\u003e resultNode = NodeUtils.findFirstSubNode(\n                NodeUtils.createNodeRelRoot(relNode1), NodeUtils.createNodeRelRoot(relNode2));\n        System.out.println(context.toSql(resultNode.getPayload()));\n\n        //register public sub sql and materialized view and rewrite query sql\n        context.addMaterializedView(\"materialized_view_1\", resultNode.getPayload());\n        Pair\u003cRelNode, List\u003cRelOptMaterialization\u003e\u003e rewriteQuery1Result = context.materializedViewOpt(relNode1);\n        Pair\u003cRelNode, List\u003cRelOptMaterialization\u003e\u003e rewriteQuery2Result = context.materializedViewOpt(relNode2);\n        System.out.println(\"=======================\");\n        System.out.println(context.toSql(rewriteQuery1Result.left));\n        System.out.println(\"-----------------------\");\n        System.out.println(context.toSql(rewriteQuery2Result.left));\n    }\n    ```   \n - Show result\n    ```text\n    SELECT d1, SUM(m1) s1, SUM(m2) s2\n    FROM default_db.test\n    WHERE d1 = 'bbb' OR d1 = 'aaa'\n    GROUP BY d1\n    =======================\n    SELECT d1, s1\n    FROM default_db.materialized_view_1\n    WHERE d1 = 'aaa'\n    -----------------------\n    SELECT d1, s2\n    FROM default_db.materialized_view_1\n    WHERE d1 = 'bbb'\n    ``` \n - [Learning more](doc/analayzer.md)  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzicat%2Fcoron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzicat%2Fcoron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzicat%2Fcoron/lists"}