From ce9ff226fd7eb4c00a354fa94cb79fc435785156 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 2 Dec 2026 12:43:37 +0100 Subject: [PATCH] fix: carry an overloaded partitioning function by its signature, leave the default hash to the copy Co-Authored-By: Claude Opus 5.5 --- .../src/datatable_extensions.rs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/windmill-api-workspaces/src/datatable_extensions.rs b/backend/windmill-api-workspaces/src/datatable_extensions.rs index 55bd1f2bc1..9a8c6a685b 100644 --- a/backend/windmill-api-workspaces/src/datatable_extensions.rs +++ b/backend/windmill-api-workspaces/src/datatable_extensions.rs @@ -75,7 +75,9 @@ struct Dimension { time_interval: Option, integer_interval: Option, num_partitions: Option, - /// The function the column's values go through before they are partitioned, qualified. + /// The function the column's values go through before they are partitioned, qualified and + /// with its argument, as the catalog names it without one and it may be overloaded. None for + /// TimescaleDB's own hash, whose schema depends on the extension's version. partitioning_func: Option, } @@ -358,9 +360,17 @@ async fn read_hypertables( .query( "SELECT d.hypertable_schema::text, d.hypertable_name::text, d.column_name::text, d.time_interval::text, d.integer_interval::bigint, d.num_partitions::smallint, - CASE WHEN c.partitioning_func IS NOT NULL - THEN format('%I.%I', c.partitioning_func_schema, c.partitioning_func) - END + (SELECT format('%I.%I(%s)', n.nspname, p.proname, + format_type(p.proargtypes[0], NULL)) + FROM pg_proc p JOIN pg_namespace n ON n.oid = p.pronamespace + WHERE n.nspname = c.partitioning_func_schema + AND p.proname = c.partitioning_func + AND p.pronargs = 1 + AND p.proargtypes[0] IN (c.column_type, 'anyelement'::regtype) + AND NOT (p.proname = 'get_partition_hash' + AND n.nspname IN ('_timescaledb_internal', '_timescaledb_functions')) + ORDER BY p.proargtypes[0] = c.column_type DESC + LIMIT 1) FROM timescaledb_information.dimensions d JOIN timescaledb_information.hypertables h ON h.hypertable_schema = d.hypertable_schema @@ -879,7 +889,7 @@ impl ExtensionPlan { Some(func) => { params.push(func); format!( - ", {}partitioning_func => ${}::text::regproc", + ", {}partitioning_func => ${}::text::regprocedure::oid::regproc", if i == 0 { "time_" } else { "" }, params.len() )