---
title: "User-defined functions in ClickHouse Cloud"
description: "ClickHouse SQL user-defined functions, now available in ClickHouse Cloud, can reconstruct a file's full commit history across renames in git-import data."
url: "https://swe.quest/articles/user-defined-functions-in-clickhouse-cloud-33c541eadcfd2cd4"
canonical: "https://clickhouse.com/blog/user-defined-functions-clickhouse-udfs"
source: "ClickHouse"
published: "2022-12-08"
difficulty: "medium"
kind: "How-to"
reading_minutes: 6
tags: ["sql","analytics","version-control"]
---

# User-defined functions in ClickHouse Cloud

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2022-12-08, 6 min read, How-to. Original: [https://clickhouse.com/blog/user-defined-functions-clickhouse-udfs](https://clickhouse.com/blog/user-defined-functions-clickhouse-udfs)

## Summary

ClickHouse SQL user-defined functions, now available in ClickHouse Cloud, can reconstruct a file's full commit history across renames in git-import data. ClickHouse lacks recursive CTEs and UDFs cannot recurse, so the workaround chains six UDFs that each call the next. Each one looks up the file's previous path from Rename/Add rows and appends it to an array, which caps the rename depth at five. The resulting array then filters the history with \`path IN file\_path\_history(...)\`. Fixing the data at insert time with a stable file ID is noted as the cleaner alternative.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Version control](https://swe.quest/tags/version-control.md) (Engineering practices)

## Prerequisites

- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- ClickHouse queries ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))

## Keywords

ClickHouse, ClickHouse Cloud, git-import, user-defined functions, recursive CTE

## Related posts

- [ClickHouse 22.11 Release](https://swe.quest/articles/clickhouse-22-11-release-1b5288455bc4594b.md): ClickHouse · 2022-12-01 · Medium · 5 min read · Analytics & OLAP, SQL, Databases
  ClickHouse 22.11 ships 15 new features, 5 performance optimisations and 32 bug fixes, headlined by composite time intervals, recursive \*\* glob patterns, Spark-compatibility functions, INSERT retries and SELECT support for Apache Hudi and Delta Lake.
- [ClickHouse Release 26.3](https://swe.quest/articles/clickhouse-release-26-3-ea6c8bff46efb19b.md): ClickHouse · 2026-04-07 · Medium · 15 min read · Analytics & OLAP, Query engines, Storage engines, SQL, WebAssembly
  ClickHouse 26.3 ships 27 features, 40 performance optimizations and 202 bug fixes.
- [ClickHouse Newsletter July 2023: Seeing Clearly](https://swe.quest/articles/clickhouse-newsletter-july-2023-seeing-clearly-a153c241f5923252.md): ClickHouse · 2023-07-24 · Medium · 10 min read · Analytics & OLAP, SQL, Databases
  ClickHouse v23.6 adds 10 features, 12 performance optimisations and 31 bug fixes.
- [ClickHouse and dbt - A Gift from the Community](https://swe.quest/articles/clickhouse-and-dbt-a-gift-from-the-community-edc7ddee62ee1cfc.md): ClickHouse · 2023-02-01 · Medium · 7 min read · Analytics & OLAP, Data pipelines, Open source
  The dbt-clickhouse adapter, started by community contributor Dmitriy Sokolov and later taken over as a vendor-supported plugin, maps dbt's view, table, incremental and ephemeral materializations onto ClickHouse features.
- [Clone massive tables instantly and experiment safely in ClickHouse](https://swe.quest/articles/clone-massive-tables-instantly-and-experiment-safely-in-clickhouse-98995e4944ae2cbf.md): ClickHouse · 2026-02-24 · Medium · 8 min read · Storage engines, Analytics & OLAP, Databases, Testing
  ClickHouse's \`CREATE TABLE ... CLONE AS\` creates a full, independent copy of a table almost instantly, without copying any data.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
