fix: carry an overloaded partitioning function by its signature, leave the default hash to the copy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-12-02 12:43:37 +01:00
co-authored by Claude Opus 5.5
parent 63adb2afb9
commit ce9ff226fd
@@ -75,7 +75,9 @@ struct Dimension {
time_interval: Option<String>,
integer_interval: Option<i64>,
num_partitions: Option<i16>,
/// 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<String>,
}
@@ -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()
)