{"id":13679135,"url":"https://github.com/Ecwid/clickhouse-client","last_synced_at":"2025-04-29T16:31:09.350Z","repository":{"id":34034568,"uuid":"165172386","full_name":"Ecwid/clickhouse-client","owner":"Ecwid","description":"Java/Kotlin client for ClickHouse","archived":false,"fork":false,"pushed_at":"2025-04-15T03:29:59.000Z","size":363,"stargazers_count":27,"open_issues_count":3,"forks_count":9,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-15T04:28:05.688Z","etag":null,"topics":["clickhouse","clickhouse-client","java","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ecwid.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,"zenodo":null}},"created_at":"2019-01-11T03:24:08.000Z","updated_at":"2025-04-15T03:28:14.000Z","dependencies_parsed_at":"2024-03-20T12:30:32.291Z","dependency_job_id":"af239f6b-9c85-45a1-b224-f09b3c5c7a3f","html_url":"https://github.com/Ecwid/clickhouse-client","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ecwid%2Fclickhouse-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ecwid%2Fclickhouse-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ecwid%2Fclickhouse-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ecwid%2Fclickhouse-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ecwid","download_url":"https://codeload.github.com/Ecwid/clickhouse-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251540105,"owners_count":21605843,"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","clickhouse-client","java","kotlin"],"created_at":"2024-08-02T13:01:02.325Z","updated_at":"2025-04-29T16:31:04.330Z","avatar_url":"https://github.com/Ecwid.png","language":"Kotlin","readme":"# clickhouse-client\n\nJava/Kotlin client for ClickHouse (https://clickhouse.com)\n\n## How to use\n\nThere are three different clients, from raw low-level client to simple object mapper.\n\n### Mapped client (transparently converts response rows into your POJO)\n```java\nHttpTransport httpTransport = new ApacheHttpClientTransport();\nClickHouseMappedClient client = new ClickHouseMappedClient(httpTransport);\n\ntry (MappedResponse\u003cUser\u003e response = client.select(\"http://localhost:8123\", \"SELECT * FROM user\", User::convert)) {\n    for (User user : response) {\n        System.out.println(user);\n    }\n}\n```\n\nClass `User` and `convert` function can be something like this\n```java\nclass User {\n\n    private final String name;\n    private final int age;\n\n    public User(String name, int age) {\n        this.name = name;\n        this.age = age;\n    }\n\n    public static User convert(TypedRow row) {\n        String name = row.getString(\"name\");\n        int age = row.getInt8(\"age\");\n        return new User(name, age);\n    }\n}\n```\n\n### Typed client (looks like JDBC ResultSet class)\n```java\nHttpTransport httpTransport = new ApacheHttpClientTransport();\nClickHouseTypedClient client = new ClickHouseTypedClient(httpTransport);\n\ntry (TypedResponse response = client.select(\"http://localhost:8123\", \"SELECT * FROM table\")) {\n    for (TypedRow typedRow : response) {\n        int firstValue = typedRow.getInt32(1);\n        Date secondValue = typedRow.getDateTime(2);\n        List\u003cInteger\u003e thirdValue = typedRow.getInt32Array(3);\n\n        System.out.println(firstValue + \":\" + secondValue + \":\" + thirdValue);\n    }\n}\n```\n\n### Raw client (very low level, use if you want to control everything)\n\n```java\nHttpTransport httpTransport = new ApacheHttpClientTransport();\nClickHouseRawClient client = new ClickHouseRawClient(httpTransport);\n\ntry (RawResponse response = client.select(\"http://localhost:8123\", \"SELECT * FROM table\")) {\n    for (RawRow row : response) {\n        System.out.println(row);\n    }\n}\n```\n\n\n## How to add clickhouse-client into your project\n### Gradle\n```\ncompile \"com.ecwid.clickhouse:clickhouse-client:0.15.0\"\n```\n### Maven\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.ecwid.clickhouse\u003c/groupId\u003e\n  \u003cartifactId\u003eclickhouse-client\u003c/artifactId\u003e\n  \u003cversion\u003e0.15.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## How to enable metrics in clickhouse-client\n### Use prometheus metrics\n\nAdd prometheus metric dependency to your project\n\ngradle\n```\ncompile \"io.prometheus:prometheus-metrics-core:1.2.0\"\n```\n\nInject metrics collector on instantiate client\n```java\nHttpTransport httpTransport = new ApacheHttpClientTransport();\nClickHouseMappedClient client = new ClickHouseMappedClient(httpTransport, DefaultMetrics.INSTANCE.getPROMETHEUS());\n```\n\n### Use custom metrics collector\nAdd implementation of `com.ecwid.clickhouse.metrics.Metrics` interface\n```java\nimport com.ecwid.clickhouse.metrics.Metrics;\nimport org.jetbrains.annotations.NotNull;\n\npublic class DummyMetrics implements Metrics {\n    @Override\n    public void measureRequest(@NotNull String host, int statusCode) {\n        // Measure request to host with received http status code\n    }\n\n    @NotNull\n    @Override\n    public AutoCloseable startRequestTimer(@NotNull String host) {\n        // start measuring request\n        final long startedAt = System.currentTimeMillis();\n        return new AutoCloseable() {\n            @Override\n            public void close() throws Exception {\n                final long completedAt = System.currentTimeMillis();\n                // measure request time to host\n            }\n        };\n    }\n}\n```\n\nAnd use it on instantiate client:\n```java\nHttpTransport httpTransport = new ApacheHttpClientTransport();\nClickHouseMappedClient client = new ClickHouseMappedClient(httpTransport, new DummyMetrics());\n```\n","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEcwid%2Fclickhouse-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEcwid%2Fclickhouse-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEcwid%2Fclickhouse-client/lists"}