From 0ba1a128add2166984816b358b6866a7ff21b0f4 Mon Sep 17 00:00:00 2001 From: Rory Shanks Date: Fri, 13 Nov 2026 08:16:26 +0100 Subject: [PATCH] Pin PostHog UDFs to PostHog/posthog#135224 Install the executable UDFs from 2b4f414, the head of PostHog/posthog#135224. Its event, person and temporary cleaners store every top-level object and array as a JSON string of the text that was sent. The latest manifest also adds the v13 funnel functions and JSONDropKeys_v13, for 60 UDFs in total. Update the e2e cleaner assertions to expect string-encoded nested values and add assertions for every v13 function. Co-Authored-By: Claude Opus 5.5 --- clickhouse-util-udfs.yml | 2 +- docs/setup.md | 2 +- e2e/sql/insert.sql | 2 +- e2e/sql/udfs.sql | 25 ++++++++++++++++++++----- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/clickhouse-util-udfs.yml b/clickhouse-util-udfs.yml index 2829ccf..88072a8 100644 --- a/clickhouse-util-udfs.yml +++ b/clickhouse-util-udfs.yml @@ -1,5 +1,5 @@ repository: PostHog/posthog -revision: 542f8dc033d2850bfa2b3094be07716475f0516c +revision: 2b4f41441705e283bc413090ce045bdee9ef39ec manifest_paths: - docker/clickhouse/user_defined_function.xml - posthog/user_scripts/latest_user_defined_function.xml diff --git a/docs/setup.md b/docs/setup.md index 7a4333a..03e09bb 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -16,7 +16,7 @@ The worker installs all executable UDFs from PostHog's source and deployment manifests at the commit pinned in `clickhouse-util-udfs.yml`. Both bundled ClickHouse builds expose the same functions, including `JSONCleanPostHogEvent`, `JSONDropKeysPool`, `decompress`, the individual property cleaners, and the -unversioned, `v11`, and `v12` funnel functions, including JSON and debug variants. +unversioned, `v11`, `v12`, and `v13` funnel functions, including JSON and debug variants. Upstream commands, argument types, pool settings, and launch scripts are preserved. `JSONCleanPostHogEvent(properties, person_properties)` returns a named tuple with diff --git a/e2e/sql/insert.sql b/e2e/sql/insert.sql index df404f8..61ebd2c 100644 --- a/e2e/sql/insert.sql +++ b/e2e/sql/insert.sql @@ -12,7 +12,7 @@ SELECT event_date, JSONCleanPostHogTemporaryProperties( concat('{"$set":{"id":', toString(id), '},"permanent":true}') - ) = concat('{"$set":{"id":', toString(id), '}}') AND s3_migrated AS migrated + ) = concat('{"$set":"{\\"id\\":', toString(id), '}"}') AND s3_migrated AS migrated FROM ( SELECT * FROM src.events WHERE id % 3 = 0 diff --git a/e2e/sql/udfs.sql b/e2e/sql/udfs.sql index 769d2d9..51ea74a 100644 --- a/e2e/sql/udfs.sql +++ b/e2e/sql/udfs.sql @@ -1,4 +1,4 @@ --- PostHog 542f8dc033d2850bfa2b3094be07716475f0516c (PostHog/posthog#111330): all 45 executable UDFs. +-- PostHog 2b4f41441705e283bc413090ce045bdee9ef39ec (PostHog/posthog#135224): all 60 executable UDFs. -- Empty funnels return no conversions; debug functions echo valid JSON. WITH toUInt8(2) AS steps, @@ -31,11 +31,11 @@ SELECT throwIf(isValidJSON(aggregate_funnel_test(steps, window, 'first_touch', 'ordered', empty_6, empty_2, empty_3)) = 0, 'aggregate_funnel_test failed'), throwIf(isValidJSON(aggregate_funnel_array_trends_test(from_step, steps, steps, window, 'first_touch', 'ordered', empty_6, empty_9)) = 0, 'aggregate_funnel_array_trends_test failed'), throwIf(JSONDropKeys(['a'])('{"a":1,"b":2}') != '{"b":2}', 'JSONDropKeys failed'), - throwIf(JSONCleanPostHogEvent('{"$set":{"score":7},"plan":null,"custom":"kept"}', '{"email":null}') != ('{"custom":"kept"}', '{"$set":{"score":7}}', '{}', ['plan'], [], ['email']), 'JSONCleanPostHogEvent failed'), + throwIf(JSONCleanPostHogEvent('{"$set":{"score":7},"plan":null,"custom":"kept"}', '{"email":null}') != ('{"custom":"kept"}', '{"$set":"{\\"score\\":7}"}', '{}', ['plan'], [], ['email']), 'JSONCleanPostHogEvent failed'), throwIf(JSONCleanPostHogEvent('{"$sent_at":"2026-01-01","$sdk_debug_current_session_duration":5,"$sdk_debug_retry":1}', '{}') != ('{"$sent_at":"2026-01-01","$sdk_debug_current_session_duration":5}', '{"$sdk_debug_retry":1}', '{}', [], [], []), 'JSONCleanPostHogEvent permanent keys failed'), throwIf(JSONCleanPostHogEventProperties('{"a":1,"b":null}') != '{"a":1}', 'JSONCleanPostHogEventProperties failed'), throwIf(JSONCleanPostHogPersonProperties('{"a":1,"b":null}') != '{"a":1}', 'JSONCleanPostHogPersonProperties failed'), - throwIf(JSONCleanPostHogTemporaryProperties('{"$set":{"a":1},"b":2}') != '{"$set":{"a":1}}', 'JSONCleanPostHogTemporaryProperties failed'), + throwIf(JSONCleanPostHogTemporaryProperties('{"$set":{"a":1},"b":2}') != '{"$set":"{\\"a\\":1}"}', 'JSONCleanPostHogTemporaryProperties failed'), throwIf(JSONStripEmptyStringsAndNulls('{"a":1,"b":null,"c":""}') != '{"a":1}', 'JSONStripEmptyStringsAndNulls failed'), throwIf(decompress(unhex('170000006068656c6c6f200600d06f2068656c6c6f2068656c6c6f'), 'LZ4SizePrefixed') != 'hello hello hello hello', 'decompress failed'), throwIf(JSONDropKeysPool('{"a":1,"b":2}', ['a']) != '{"b":2}', 'JSONDropKeysPool failed'), @@ -61,7 +61,22 @@ SELECT throwIf(notEmpty(aggregate_funnel_cohort_trends_json_v12(from_step, steps, steps, window, 'first_touch', 'ordered', empty_4, empty_10)), 'aggregate_funnel_cohort_trends_json_v12 failed'), throwIf(isValidJSON(aggregate_funnel_test_v12(steps, window, 'first_touch', 'ordered', empty_6, empty_2, empty_3)) = 0, 'aggregate_funnel_test_v12 failed'), throwIf(isValidJSON(aggregate_funnel_array_trends_test_v12(from_step, steps, steps, window, 'first_touch', 'ordered', empty_6, empty_9)) = 0, 'aggregate_funnel_array_trends_test_v12 failed'), - throwIf(JSONDropKeys_v12(['a'])('{"a":1,"b":2}') != '{"b":2}', 'JSONDropKeys_v12 failed'); + throwIf(JSONDropKeys_v12(['a'])('{"a":1,"b":2}') != '{"b":2}', 'JSONDropKeys_v12 failed'), + throwIf(notEmpty(aggregate_funnel_v13(steps, window, 'first_touch', 'ordered', empty_1, empty_2, empty_3)), 'aggregate_funnel_v13 failed'), + throwIf(notEmpty(aggregate_funnel_cohort_v13(steps, window, 'first_touch', 'ordered', empty_4, empty_2, empty_5)), 'aggregate_funnel_cohort_v13 failed'), + throwIf(notEmpty(aggregate_funnel_array_v13(steps, window, 'first_touch', 'ordered', empty_6, empty_2, empty_7)), 'aggregate_funnel_array_v13 failed'), + throwIf(notEmpty(aggregate_funnel_trends_v13(from_step, steps, steps, window, 'first_touch', 'ordered', empty_1, empty_8)), 'aggregate_funnel_trends_v13 failed'), + throwIf(notEmpty(aggregate_funnel_array_trends_v13(from_step, steps, steps, window, 'first_touch', 'ordered', empty_6, empty_9)), 'aggregate_funnel_array_trends_v13 failed'), + throwIf(notEmpty(aggregate_funnel_cohort_trends_v13(from_step, steps, steps, window, 'first_touch', 'ordered', empty_4, empty_10)), 'aggregate_funnel_cohort_trends_v13 failed'), + throwIf(notEmpty(aggregate_funnel_json_v13(steps, window, 'first_touch', 'ordered', empty_1, empty_2, empty_3)), 'aggregate_funnel_json_v13 failed'), + throwIf(notEmpty(aggregate_funnel_cohort_json_v13(steps, window, 'first_touch', 'ordered', empty_4, empty_2, empty_5)), 'aggregate_funnel_cohort_json_v13 failed'), + throwIf(notEmpty(aggregate_funnel_array_json_v13(steps, window, 'first_touch', 'ordered', empty_6, empty_2, empty_7)), 'aggregate_funnel_array_json_v13 failed'), + throwIf(notEmpty(aggregate_funnel_trends_json_v13(from_step, steps, steps, window, 'first_touch', 'ordered', empty_1, empty_8)), 'aggregate_funnel_trends_json_v13 failed'), + throwIf(notEmpty(aggregate_funnel_array_trends_json_v13(from_step, steps, steps, window, 'first_touch', 'ordered', empty_6, empty_9)), 'aggregate_funnel_array_trends_json_v13 failed'), + throwIf(notEmpty(aggregate_funnel_cohort_trends_json_v13(from_step, steps, steps, window, 'first_touch', 'ordered', empty_4, empty_10)), 'aggregate_funnel_cohort_trends_json_v13 failed'), + throwIf(isValidJSON(aggregate_funnel_test_v13(steps, window, 'first_touch', 'ordered', empty_6, empty_2, empty_3)) = 0, 'aggregate_funnel_test_v13 failed'), + throwIf(isValidJSON(aggregate_funnel_array_trends_test_v13(from_step, steps, steps, window, 'first_touch', 'ordered', empty_6, empty_9)) = 0, 'aggregate_funnel_array_trends_test_v13 failed'), + throwIf(JSONDropKeys_v13(['a'])('{"a":1,"b":2}') != '{"b":2}', 'JSONDropKeys_v13 failed'); -- Reuse the new pools across chunks, with keys and cleaned values changing per row. SELECT throwIf(countIf( @@ -73,7 +88,7 @@ SETTINGS max_block_size = 2, max_threads = 1; SELECT throwIf(countIf( cleaned.properties != concat('{"id":', toString(number), '}') - OR cleaned.temporary_properties != concat('{"$set":{"id":', toString(number), '}}') + OR cleaned.temporary_properties != concat('{"$set":"{\\"id\\":', toString(number), '}"}') OR cleaned.person_properties != concat('{"id":', toString(number), '}') OR cleaned.properties_null_keys != ['missing'] OR cleaned.temporary_properties_null_keys != []