{"id":18732495,"url":"https://github.com/metrico/clickhouse-udf-vlang","last_synced_at":"2026-01-26T00:08:22.938Z","repository":{"id":115480560,"uuid":"469364381","full_name":"metrico/clickhouse-udf-vlang","owner":"metrico","description":"Example vlang UDF for Clickhouse","archived":false,"fork":false,"pushed_at":"2022-09-24T17:22:22.000Z","size":22,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-19T23:08:38.579Z","etag":null,"topics":["clickhouse","cloki","udf","user-defined-function","v","vlang"],"latest_commit_sha":null,"homepage":"","language":"V","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/metrico.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,"zenodo":null}},"created_at":"2022-03-13T12:26:47.000Z","updated_at":"2024-10-24T16:38:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"c3a9559e-8111-4141-8272-bb431398887c","html_url":"https://github.com/metrico/clickhouse-udf-vlang","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/metrico/clickhouse-udf-vlang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metrico%2Fclickhouse-udf-vlang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metrico%2Fclickhouse-udf-vlang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metrico%2Fclickhouse-udf-vlang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metrico%2Fclickhouse-udf-vlang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metrico","download_url":"https://codeload.github.com/metrico/clickhouse-udf-vlang/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metrico%2Fclickhouse-udf-vlang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28761941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T23:06:19.311Z","status":"ssl_error","status_checked_at":"2026-01-25T23:03:50.555Z","response_time":113,"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":["clickhouse","cloki","udf","user-defined-function","v","vlang"],"created_at":"2024-11-07T15:06:25.815Z","updated_at":"2026-01-26T00:08:22.927Z","avatar_url":"https://github.com/metrico.png","language":"V","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://vlang.io/img/veasel.png\" width=420\u003e\n\n# V ClickHouse UDF\n\u003e ClickHouse can call any external executable program or script to process data.\n\nThis basic example illustrates a simple `sum` [V](https://vlang.io/) powered function for [Clickhouse UDF](https://clickhouse.com/docs/en/sql-reference/functions/#executable-user-defined-functions) usage\n\n\u003cbr\u003e\n\n### V Function\nTo get started, create an baseline vlang application with the following features:\n\n- [x] read input from stdin\n- [x] parse tab separated columns\n- [ ] do something with data\n- [x] return some output\n\nHere's an example `sum` function:\n```\nimport os\n\nfn main() {\n        // Parse stdin to array\n        data := os.get_lines()\n        for line in data {\n           // split tabSeparated columns\n           columns := line.split('\\t')\n           // sum two integers\n           sum := columns[0].int() + columns[1].int()\n           // return a result\n           println(sum)\n        }\n}\n```\n\nCompile and store into the ClickHouse UDF script directory:\n```\nv -o /var/lib/clickhouse/user-scripts/vlang-udf -prod .\n```\n\nThe final static executable size is \u003c ~100KB all inclusive!\n```\n-rwxr-xr-x   1 root root  98K Mar 13 12:49 vlang-udf*\n```\n\n### ClickHouse UDF\nCreate a [UDF Function XML](https://clickhouse.com/docs/en/sql-reference/functions/#executable-user-defined-functions) to invoke your vlang binary\n\nDefine the _input and output_ [format](https://clickhouse.com/docs/en/interfaces/formats) our function requires _(UInt64, string, etc)_\n\n```\n\u003cfunctions\u003e\n    \u003cfunction\u003e\n        \u003ctype\u003eexecutable\u003c/type\u003e\n        \u003cname\u003ev_sum\u003c/name\u003e\n        \u003creturn_type\u003eUInt64\u003c/return_type\u003e\n        \u003cargument\u003e\n            \u003ctype\u003eUInt64\u003c/type\u003e\n        \u003c/argument\u003e\n        \u003cargument\u003e\n            \u003ctype\u003eUInt64\u003c/type\u003e\n        \u003c/argument\u003e\n        \u003cformat\u003eTabSeparated\u003c/format\u003e\n        \u003ccommand\u003evlang-udf\u003c/command\u003e\n        \u003clifetime\u003e0\u003c/lifetime\u003e\n    \u003c/function\u003e\n\u003c/functions\u003e\n```\n\n\u003e MUST use directory `/var/lib/clickhouse/user-scripts` to store both user-scripts and executable udf\n\n\n### Usage\n```\nSELECT v_sum(10, 20)\n\nQuery id: f98a5f83-4e94-41d0-9d9f-78b37d3af152\n\n┌─v_sum(10, 20)─────┐\n│                30 │\n└───────────────────┘\n\n1 rows in set. Elapsed: 0.006 sec. \n```\n\n\u003cbr\u003e\n\nThat's all it takes! Go create your superfast v powered UDF function for fun and profit!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetrico%2Fclickhouse-udf-vlang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetrico%2Fclickhouse-udf-vlang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetrico%2Fclickhouse-udf-vlang/lists"}