From 70ed6e14d6c1e80b3db449934cdce55c8f6cb1dd Mon Sep 17 00:00:00 2001 From: estebanzimanyi <26899974+estebanzimanyi@users.noreply.github.com> Date: Fri, 31 Jul 2026 13:51:57 +0000 Subject: [PATCH 1/2] Regenerate the UDF surface from MobilityDB master --- src/generated/generated_temporal_udfs.cpp | 156 +++++++++++++++++----- 1 file changed, 121 insertions(+), 35 deletions(-) diff --git a/src/generated/generated_temporal_udfs.cpp b/src/generated/generated_temporal_udfs.cpp index 182790eb..416d61ab 100644 --- a/src/generated/generated_temporal_udfs.cpp +++ b/src/generated/generated_temporal_udfs.cpp @@ -5723,6 +5723,41 @@ static void Gen_tjsonb_array_length(DataChunk &args, ExpressionState &, Vector & }); } +static void Gen_tjsonb_delete(DataChunk &args, ExpressionState &, Vector &result) { + EnsureMeosThreadInitialized(); + BinaryExecutor::ExecuteWithNulls(args.data[0], args.data[1], result, args.size(), + [&](string_t in, string_t a2, ValidityMask &mask, idx_t idx) -> string_t { + Temporal *t = BlobToTemporal(in); + text *a2t = MakeText(a2); + Temporal *r = tjsonb_delete(t, a2t); + free(a2t); free(t); + return TemporalToBlobN(result, r, mask, idx); + }); +} + +static void Gen_tjsonb_delete_index(DataChunk &args, ExpressionState &, Vector &result) { + EnsureMeosThreadInitialized(); + BinaryExecutor::ExecuteWithNulls(args.data[0], args.data[1], result, args.size(), + [&](string_t in, int32_t a2, ValidityMask &mask, idx_t idx) -> string_t { + Temporal *t = BlobToTemporal(in); + Temporal *r = tjsonb_delete_index(t, a2); + free(t); + return TemporalToBlobN(result, r, mask, idx); + }); +} + +static void Gen_tjsonb_exists(DataChunk &args, ExpressionState &, Vector &result) { + EnsureMeosThreadInitialized(); + BinaryExecutor::ExecuteWithNulls(args.data[0], args.data[1], result, args.size(), + [&](string_t in, string_t a2, ValidityMask &mask, idx_t idx) -> string_t { + Temporal *t = BlobToTemporal(in); + text *a2t = MakeText(a2); + Temporal *r = tjsonb_exists(t, a2t); + free(a2t); free(t); + return TemporalToBlobN(result, r, mask, idx); + }); +} + static void Gen_tjsonb_pretty(DataChunk &args, ExpressionState &, Vector &result) { EnsureMeosThreadInitialized(); UnaryExecutor::ExecuteWithNulls(args.data[0], result, args.size(), @@ -5783,6 +5818,31 @@ static void Gen_tjsonb_minus_value(DataChunk &args, ExpressionState &, Vector &r } +// ===== @ingroup meos_json_set_json ===== +static void Gen_jsonbset_delete_index(DataChunk &args, ExpressionState &, Vector &result) { + EnsureMeosThreadInitialized(); + BinaryExecutor::Execute(args.data[0], args.data[1], result, args.size(), + [&](string_t a, int32_t a2) { + Set *s = BlobToSet(a); + Set *r = jsonbset_delete_index(s, a2); + free(s); + return SetToBlob(result, r); + }); +} + +static void Gen_jsonbset_delete(DataChunk &args, ExpressionState &, Vector &result) { + EnsureMeosThreadInitialized(); + BinaryExecutor::Execute(args.data[0], args.data[1], result, args.size(), + [&](string_t a, string_t a2) { + Set *s = BlobToSet(a); + text *t2 = MakeText(a2); + Set *r = jsonbset_delete(s, t2); + free(t2); free(s); + return SetToBlob(result, r); + }); +} + + // ===== @ingroup meos_npoint_base_accessor ===== static void Gen_npoint_position(DataChunk &args, ExpressionState &, Vector &result) { EnsureMeosThreadInitialized(); @@ -17380,12 +17440,18 @@ static void RegisterGenerated_meos_json_conversion(ExtensionLoader &loader) { } static void RegisterGenerated_meos_json_json(ExtensionLoader &loader) { - RegisterSerializedScalarFunction(loader, ScalarFunction("jsonb_concat", {TJsonbTypes::tjsonb(), TJsonbTypes::tjsonb()}, TJsonbTypes::tjsonb(), Gen_concat_tjsonb_tjsonb)); + RegisterSerializedScalarFunction(loader, ScalarFunction("tjsonb_concat", {TJsonbTypes::tjsonb(), TJsonbTypes::tjsonb()}, TJsonbTypes::tjsonb(), Gen_concat_tjsonb_tjsonb)); RegisterSerializedScalarFunction(loader, ScalarFunction("||", {TJsonbTypes::tjsonb(), TJsonbTypes::tjsonb()}, TJsonbTypes::tjsonb(), Gen_concat_tjsonb_tjsonb)); RegisterSerializedScalarFunction(loader, ScalarFunction("tjsonb_contains", {TJsonbTypes::tjsonb(), TJsonbTypes::tjsonb()}, TemporalTypes::tbool(), Gen_contains_tjsonb_tjsonb)); RegisterSerializedScalarFunction(loader, ScalarFunction("contains", {TJsonbTypes::tjsonb(), TJsonbTypes::tjsonb()}, TemporalTypes::tbool(), Gen_contains_tjsonb_tjsonb)); RegisterSerializedScalarFunction(loader, ScalarFunction("@>", {TJsonbTypes::tjsonb(), TJsonbTypes::tjsonb()}, TemporalTypes::tbool(), Gen_contains_tjsonb_tjsonb)); RegisterSerializedScalarFunction(loader, ScalarFunction("tjsonb_array_length", {TJsonbTypes::tjsonb()}, TemporalTypes::tint(), Gen_tjsonb_array_length)); + RegisterSerializedScalarFunction(loader, ScalarFunction("tjsonb_delete", {TJsonbTypes::tjsonb(), LogicalType::VARCHAR}, TJsonbTypes::tjsonb(), Gen_tjsonb_delete)); + RegisterSerializedScalarFunction(loader, ScalarFunction("-", {TJsonbTypes::tjsonb(), LogicalType::VARCHAR}, TJsonbTypes::tjsonb(), Gen_tjsonb_delete)); + RegisterSerializedScalarFunction(loader, ScalarFunction("tjsonb_delete_index", {TJsonbTypes::tjsonb(), LogicalType::INTEGER}, TJsonbTypes::tjsonb(), Gen_tjsonb_delete_index)); + RegisterSerializedScalarFunction(loader, ScalarFunction("-", {TJsonbTypes::tjsonb(), LogicalType::INTEGER}, TJsonbTypes::tjsonb(), Gen_tjsonb_delete_index)); + RegisterSerializedScalarFunction(loader, ScalarFunction("tjsonb_exists", {TJsonbTypes::tjsonb(), LogicalType::VARCHAR}, TemporalTypes::tbool(), Gen_tjsonb_exists)); + RegisterSerializedScalarFunction(loader, ScalarFunction("?", {TJsonbTypes::tjsonb(), LogicalType::VARCHAR}, TemporalTypes::tbool(), Gen_tjsonb_exists)); RegisterSerializedScalarFunction(loader, ScalarFunction("tjsonb_pretty", {TJsonbTypes::tjsonb()}, TemporalTypes::ttext(), Gen_tjsonb_pretty)); RegisterSerializedScalarFunction(loader, ScalarFunction("tjsonb_strip_nulls", {TJsonbTypes::tjsonb(), LogicalType::BOOLEAN}, TJsonbTypes::tjsonb(), Gen_tjsonb_strip_nulls)); RegisterSerializedScalarFunction(loader, ScalarFunction("tjsonb_strip_nulls", {TJsonbTypes::tjsonb()}, TJsonbTypes::tjsonb(), Gen_tjsonb_strip_nulls_d)); @@ -17396,6 +17462,13 @@ static void RegisterGenerated_meos_json_restrict(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("minusValue", {TJsonbTypes::tjsonb(), TJsonbTypes::jsonb()}, TJsonbTypes::tjsonb(), Gen_tjsonb_minus_value)); } +static void RegisterGenerated_meos_json_set_json(ExtensionLoader &loader) { + RegisterSerializedScalarFunction(loader, ScalarFunction("jsonbset_delete_index", {SetTypes::intset(), LogicalType::INTEGER}, SetTypes::intset(), Gen_jsonbset_delete_index)); + RegisterSerializedScalarFunction(loader, ScalarFunction("-", {SetTypes::intset(), LogicalType::INTEGER}, SetTypes::intset(), Gen_jsonbset_delete_index)); + RegisterSerializedScalarFunction(loader, ScalarFunction("jsonbset_delete", {SetTypes::textset(), LogicalType::VARCHAR}, SetTypes::textset(), Gen_jsonbset_delete)); + RegisterSerializedScalarFunction(loader, ScalarFunction("-", {SetTypes::textset(), LogicalType::VARCHAR}, SetTypes::textset(), Gen_jsonbset_delete)); +} + static void RegisterGenerated_meos_npoint_base_accessor(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("position", {NpointTypes::npoint()}, LogicalType::DOUBLE, Gen_npoint_position)); RegisterSerializedScalarFunction(loader, ScalarFunction("route", {NpointTypes::npoint()}, LogicalType::BIGINT, Gen_npoint_route)); @@ -17471,7 +17544,7 @@ static void RegisterGenerated_meos_setspan_accessor(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("getValues", {SetTypes::textset()}, LogicalType::LIST(LogicalType::VARCHAR), Gen_textset_values)); RegisterSerializedScalarFunction(loader, ScalarFunction("getValues", {SetTypes::tstzset()}, LogicalType::LIST(LogicalType::TIMESTAMP_TZ), Gen_tstzset_values)); for (auto &type : SpanTypes::AllTypes()) { - RegisterSerializedScalarFunction(loader, ScalarFunction("span_hash", {type}, LogicalType::UINTEGER, Gen_span_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {type}, LogicalType::UINTEGER, Gen_span_hash)); RegisterSerializedScalarFunction(loader, ScalarFunction("lower_inc", {type}, LogicalType::BOOLEAN, Gen_span_lower_inc)); RegisterSerializedScalarFunction(loader, ScalarFunction("lower_inc", {type}, LogicalType::BOOLEAN, Gen_span_upper_inc)); } @@ -17509,7 +17582,7 @@ static void RegisterGenerated_meos_setspan_accessor(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("startTimestamp", {SpansetTypes::tstzspanset()}, LogicalType::TIMESTAMP_TZ, Gen_tstzspanset_start_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("upper", {SpansetTypes::tstzspanset()}, LogicalType::TIMESTAMP_TZ, Gen_tstzspanset_upper)); for (auto &type : SpansetTypes::AllTypes()) { - RegisterSerializedScalarFunction(loader, ScalarFunction("spanset_hash", {type}, LogicalType::UINTEGER, Gen_spanset_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {type}, LogicalType::UINTEGER, Gen_spanset_hash)); RegisterSerializedScalarFunction(loader, ScalarFunction("lower_inc", {type}, LogicalType::BOOLEAN, Gen_spanset_lower_inc)); RegisterSerializedScalarFunction(loader, ScalarFunction("numSpans", {type}, LogicalType::INTEGER, Gen_spanset_num_spans)); RegisterSerializedScalarFunction(loader, ScalarFunction("lower_inc", {type}, LogicalType::BOOLEAN, Gen_spanset_upper_inc)); @@ -18285,38 +18358,38 @@ static void RegisterGenerated_meos_temporal_accessor(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("endTimestamp", {TPcpointTypes::tpcpoint()}, LogicalType::TIMESTAMP_TZ, Gen_temporal_end_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("endTimestamp", {TPcpatchTypes::tpcpatch()}, LogicalType::TIMESTAMP_TZ, Gen_temporal_end_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("endTimestamp", {NpointTypes::tnpoint()}, LogicalType::TIMESTAMP_TZ, Gen_temporal_end_timestamptz)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TemporalTypes::tint()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TemporalTypes::tbigint()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TemporalTypes::tbool()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TemporalTypes::tfloat()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TemporalTypes::ttext()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TgeompointType::tgeompoint()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TgeogpointType::tgeogpoint()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TGeometryTypes::tgeometry()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TGeographyTypes::tgeography()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {CbufferTypes::tcbuffer()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {H3indexTypes::th3index()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {QuadbinTypes::tquadbin()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TJsonbTypes::tjsonb()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TPcpointTypes::tpcpoint()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {TPcpatchTypes::tpcpatch()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash", {NpointTypes::tnpoint()}, LogicalType::UINTEGER, Gen_temporal_hash)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TemporalTypes::tint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TemporalTypes::tbigint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TemporalTypes::tbool(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TemporalTypes::tfloat(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TemporalTypes::ttext(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TgeompointType::tgeompoint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TgeogpointType::tgeogpoint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TGeometryTypes::tgeometry(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TGeographyTypes::tgeography(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {CbufferTypes::tcbuffer(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {H3indexTypes::th3index(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {QuadbinTypes::tquadbin(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TJsonbTypes::tjsonb(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TPcpointTypes::tpcpoint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {TPcpatchTypes::tpcpatch(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); - RegisterSerializedScalarFunction(loader, ScalarFunction("temporal_hash_extended", {NpointTypes::tnpoint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TemporalTypes::tint()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TemporalTypes::tbigint()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TemporalTypes::tbool()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TemporalTypes::tfloat()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TemporalTypes::ttext()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TgeompointType::tgeompoint()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TgeogpointType::tgeogpoint()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TGeometryTypes::tgeometry()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TGeographyTypes::tgeography()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {CbufferTypes::tcbuffer()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {H3indexTypes::th3index()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {QuadbinTypes::tquadbin()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TJsonbTypes::tjsonb()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TPcpointTypes::tpcpoint()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {TPcpatchTypes::tpcpatch()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {NpointTypes::tnpoint()}, LogicalType::UINTEGER, Gen_temporal_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TemporalTypes::tint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TemporalTypes::tbigint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TemporalTypes::tbool(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TemporalTypes::tfloat(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TemporalTypes::ttext(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TgeompointType::tgeompoint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TgeogpointType::tgeogpoint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TGeometryTypes::tgeometry(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TGeographyTypes::tgeography(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {CbufferTypes::tcbuffer(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {H3indexTypes::th3index(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {QuadbinTypes::tquadbin(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TJsonbTypes::tjsonb(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TPcpointTypes::tpcpoint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {TPcpatchTypes::tpcpatch(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {NpointTypes::tnpoint(), LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_temporal_hash_extended)); RegisterSerializedScalarFunction(loader, ScalarFunction("instantN", {TemporalTypes::tint(), LogicalType::INTEGER}, TemporalTypes::tint(), Gen_temporal_instant_n)); RegisterSerializedScalarFunction(loader, ScalarFunction("instantN", {TemporalTypes::tbigint(), LogicalType::INTEGER}, TemporalTypes::tbigint(), Gen_temporal_instant_n)); RegisterSerializedScalarFunction(loader, ScalarFunction("instantN", {TemporalTypes::tbool(), LogicalType::INTEGER}, TemporalTypes::tbool(), Gen_temporal_instant_n)); @@ -20021,6 +20094,8 @@ static void RegisterGenerated_meos_temporal_inout(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("asHexWKB", {TPcpointTypes::tpcpoint(), LogicalType::VARCHAR}, LogicalType::VARCHAR, Gen_temporal_as_hexwkb)); RegisterSerializedScalarFunction(loader, ScalarFunction("asHexWKB", {TPcpatchTypes::tpcpatch()}, LogicalType::VARCHAR, Gen_temporal_as_hexwkb)); RegisterSerializedScalarFunction(loader, ScalarFunction("asHexWKB", {TPcpatchTypes::tpcpatch(), LogicalType::VARCHAR}, LogicalType::VARCHAR, Gen_temporal_as_hexwkb)); + RegisterSerializedScalarFunction(loader, ScalarFunction("asHexWKB", {QuadbinTypes::tquadbin()}, LogicalType::VARCHAR, Gen_temporal_as_hexwkb)); + RegisterSerializedScalarFunction(loader, ScalarFunction("asHexWKB", {QuadbinTypes::tquadbin(), LogicalType::VARCHAR}, LogicalType::VARCHAR, Gen_temporal_as_hexwkb)); RegisterSerializedScalarFunction(loader, ScalarFunction("asHexWKB", {TemporalTypes::tbool()}, LogicalType::VARCHAR, Gen_temporal_as_hexwkb)); RegisterSerializedScalarFunction(loader, ScalarFunction("asHexWKB", {TemporalTypes::tbool(), LogicalType::VARCHAR}, LogicalType::VARCHAR, Gen_temporal_as_hexwkb)); RegisterSerializedScalarFunction(loader, ScalarFunction("asHexWKB", {TemporalTypes::tint()}, LogicalType::VARCHAR, Gen_temporal_as_hexwkb)); @@ -20130,6 +20205,8 @@ static void RegisterGenerated_meos_temporal_modif(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("deleteTime", {H3indexTypes::th3index(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, H3indexTypes::th3index(), Gen_temporal_delete_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("deleteTime", {QuadbinTypes::tquadbin(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, QuadbinTypes::tquadbin(), Gen_temporal_delete_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("deleteTime", {TJsonbTypes::tjsonb(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, TJsonbTypes::tjsonb(), Gen_temporal_delete_timestamptz)); + RegisterSerializedScalarFunction(loader, ScalarFunction("deleteTime", {TPcpointTypes::tpcpoint(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, TPcpointTypes::tpcpoint(), Gen_temporal_delete_timestamptz)); + RegisterSerializedScalarFunction(loader, ScalarFunction("deleteTime", {TPcpatchTypes::tpcpatch(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, TPcpatchTypes::tpcpatch(), Gen_temporal_delete_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("deleteTime", {NpointTypes::tnpoint(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, NpointTypes::tnpoint(), Gen_temporal_delete_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("insert", {TemporalTypes::tint(), TemporalTypes::tint(), LogicalType::BOOLEAN}, TemporalTypes::tint(), Gen_temporal_insert)); RegisterSerializedScalarFunction(loader, ScalarFunction("insert", {TemporalTypes::tbigint(), TemporalTypes::tbigint(), LogicalType::BOOLEAN}, TemporalTypes::tbigint(), Gen_temporal_insert)); @@ -20139,6 +20216,8 @@ static void RegisterGenerated_meos_temporal_modif(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("insert", {H3indexTypes::th3index(), H3indexTypes::th3index(), LogicalType::BOOLEAN}, H3indexTypes::th3index(), Gen_temporal_insert)); RegisterSerializedScalarFunction(loader, ScalarFunction("insert", {QuadbinTypes::tquadbin(), QuadbinTypes::tquadbin(), LogicalType::BOOLEAN}, QuadbinTypes::tquadbin(), Gen_temporal_insert)); RegisterSerializedScalarFunction(loader, ScalarFunction("insert", {TJsonbTypes::tjsonb(), TJsonbTypes::tjsonb(), LogicalType::BOOLEAN}, TJsonbTypes::tjsonb(), Gen_temporal_insert)); + RegisterSerializedScalarFunction(loader, ScalarFunction("insert", {TPcpointTypes::tpcpoint(), TPcpointTypes::tpcpoint(), LogicalType::BOOLEAN}, TPcpointTypes::tpcpoint(), Gen_temporal_insert)); + RegisterSerializedScalarFunction(loader, ScalarFunction("insert", {TPcpatchTypes::tpcpatch(), TPcpatchTypes::tpcpatch(), LogicalType::BOOLEAN}, TPcpatchTypes::tpcpatch(), Gen_temporal_insert)); RegisterSerializedScalarFunction(loader, ScalarFunction("merge", {TemporalTypes::tint(), TemporalTypes::tint()}, TemporalTypes::tint(), Gen_temporal_merge)); RegisterSerializedScalarFunction(loader, ScalarFunction("merge", {TemporalTypes::tbigint(), TemporalTypes::tbigint()}, TemporalTypes::tbigint(), Gen_temporal_merge)); RegisterSerializedScalarFunction(loader, ScalarFunction("merge", {TemporalTypes::tbool(), TemporalTypes::tbool()}, TemporalTypes::tbool(), Gen_temporal_merge)); @@ -20166,6 +20245,8 @@ static void RegisterGenerated_meos_temporal_modif(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("update", {H3indexTypes::th3index(), H3indexTypes::th3index(), LogicalType::BOOLEAN}, H3indexTypes::th3index(), Gen_temporal_update)); RegisterSerializedScalarFunction(loader, ScalarFunction("update", {QuadbinTypes::tquadbin(), QuadbinTypes::tquadbin(), LogicalType::BOOLEAN}, QuadbinTypes::tquadbin(), Gen_temporal_update)); RegisterSerializedScalarFunction(loader, ScalarFunction("update", {TJsonbTypes::tjsonb(), TJsonbTypes::tjsonb(), LogicalType::BOOLEAN}, TJsonbTypes::tjsonb(), Gen_temporal_update)); + RegisterSerializedScalarFunction(loader, ScalarFunction("update", {TPcpointTypes::tpcpoint(), TPcpointTypes::tpcpoint(), LogicalType::BOOLEAN}, TPcpointTypes::tpcpoint(), Gen_temporal_update)); + RegisterSerializedScalarFunction(loader, ScalarFunction("update", {TPcpatchTypes::tpcpatch(), TPcpatchTypes::tpcpatch(), LogicalType::BOOLEAN}, TPcpatchTypes::tpcpatch(), Gen_temporal_update)); RegisterSerializedScalarFunction(loader, ScalarFunction("update", {NpointTypes::tnpoint(), NpointTypes::tnpoint(), LogicalType::BOOLEAN}, NpointTypes::tnpoint(), Gen_temporal_update)); } @@ -20185,6 +20266,8 @@ static void RegisterGenerated_meos_temporal_restrict(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("afterTimestamp", {H3indexTypes::th3index(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, H3indexTypes::th3index(), Gen_temporal_after_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("afterTimestamp", {QuadbinTypes::tquadbin(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, QuadbinTypes::tquadbin(), Gen_temporal_after_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("afterTimestamp", {TJsonbTypes::tjsonb(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, TJsonbTypes::tjsonb(), Gen_temporal_after_timestamptz)); + RegisterSerializedScalarFunction(loader, ScalarFunction("afterTimestamp", {TPcpointTypes::tpcpoint(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, TPcpointTypes::tpcpoint(), Gen_temporal_after_timestamptz)); + RegisterSerializedScalarFunction(loader, ScalarFunction("afterTimestamp", {TPcpatchTypes::tpcpatch(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, TPcpatchTypes::tpcpatch(), Gen_temporal_after_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("afterTimestamp", {NpointTypes::tnpoint(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, NpointTypes::tnpoint(), Gen_temporal_after_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("atMax", {TemporalTypes::tint()}, TemporalTypes::tint(), Gen_temporal_at_max)); RegisterSerializedScalarFunction(loader, ScalarFunction("atMax", {TemporalTypes::tbigint()}, TemporalTypes::tbigint(), Gen_temporal_at_max)); @@ -20225,6 +20308,8 @@ static void RegisterGenerated_meos_temporal_restrict(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("beforeTimestamp", {H3indexTypes::th3index(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, H3indexTypes::th3index(), Gen_temporal_before_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("beforeTimestamp", {QuadbinTypes::tquadbin(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, QuadbinTypes::tquadbin(), Gen_temporal_before_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("beforeTimestamp", {TJsonbTypes::tjsonb(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, TJsonbTypes::tjsonb(), Gen_temporal_before_timestamptz)); + RegisterSerializedScalarFunction(loader, ScalarFunction("beforeTimestamp", {TPcpointTypes::tpcpoint(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, TPcpointTypes::tpcpoint(), Gen_temporal_before_timestamptz)); + RegisterSerializedScalarFunction(loader, ScalarFunction("beforeTimestamp", {TPcpatchTypes::tpcpatch(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, TPcpatchTypes::tpcpatch(), Gen_temporal_before_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("beforeTimestamp", {NpointTypes::tnpoint(), LogicalType::TIMESTAMP_TZ, LogicalType::BOOLEAN}, NpointTypes::tnpoint(), Gen_temporal_before_timestamptz)); RegisterSerializedScalarFunction(loader, ScalarFunction("minusMax", {TemporalTypes::tint()}, TemporalTypes::tint(), Gen_temporal_minus_max)); RegisterSerializedScalarFunction(loader, ScalarFunction("minusMax", {TemporalTypes::tbigint()}, TemporalTypes::tbigint(), Gen_temporal_minus_max)); @@ -20484,6 +20569,7 @@ void RegisterGeneratedTemporalUdfs(ExtensionLoader &loader) { RegisterGenerated_meos_json_conversion(loader); RegisterGenerated_meos_json_json(loader); RegisterGenerated_meos_json_restrict(loader); + RegisterGenerated_meos_json_set_json(loader); RegisterGenerated_meos_npoint_base_accessor(loader); RegisterGenerated_meos_npoint_base_srid(loader); RegisterGenerated_meos_npoint_conversion(loader); From b10a9785d2cbd95928847f94e3d4bca53069ed56 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 31 Jul 2026 17:58:33 +0200 Subject: [PATCH 2/2] Generate the value-type hash and hashExtended surface The set, span and spanset hash and hashExtended functions are now emitted by the generator as the bare overloaded hash() and hashExtended() (with a UBIGINT seed), matching the MobilityDB SQL surface. A new (container, by-value seed) -> scalar shape covers the extended variants alongside the existing unary hash. The hand-written set_hash/span_hash/spanset_hash registrations and their _hash_extended variants, together with their implementations and declarations, are removed; the generated surface now covers them. The parity tests are updated to the bare names. --- src/generated/generated_temporal_udfs.cpp | 36 ++++++++++++++ src/include/temporal/set_functions.hpp | 2 - src/include/temporal/span_functions.hpp | 2 - src/include/temporal/spanset_functions.hpp | 2 - src/temporal/set.cpp | 9 +--- src/temporal/set_functions.cpp | 32 ------------- src/temporal/span.cpp | 4 +- src/temporal/span_functions.cpp | 31 ------------ src/temporal/spanset.cpp | 9 +--- src/temporal/spanset_functions.cpp | 33 ------------- test/sql/parity/001_set.test | 24 +++++----- test/sql/parity/003_span.test | 8 ++-- test/sql/parity/007_spanset.test | 4 +- test/sql/temporal_hash.test | 12 ++--- tools/codegen_duck_udfs.py | 55 ++++++++++++++++++++++ 15 files changed, 122 insertions(+), 141 deletions(-) diff --git a/src/generated/generated_temporal_udfs.cpp b/src/generated/generated_temporal_udfs.cpp index 416d61ab..677372ed 100644 --- a/src/generated/generated_temporal_udfs.cpp +++ b/src/generated/generated_temporal_udfs.cpp @@ -6249,6 +6249,17 @@ static void Gen_set_hash(DataChunk &args, ExpressionState &, Vector &result) { }); } +static void Gen_set_hash_extended(DataChunk &args, ExpressionState &, Vector &result) { + EnsureMeosThreadInitialized(); + BinaryExecutor::Execute(args.data[0], args.data[1], result, args.size(), + [&](string_t a, uint64_t a2) { + Set *s = BlobToSet(a); + uint64_t r = set_hash_extended(s, a2); + free(s); + return r; + }); +} + static void Gen_set_num_values(DataChunk &args, ExpressionState &, Vector &result) { EnsureMeosThreadInitialized(); UnaryExecutor::Execute(args.data[0], result, args.size(), @@ -6633,6 +6644,17 @@ static void Gen_span_hash(DataChunk &args, ExpressionState &, Vector &result) { }); } +static void Gen_span_hash_extended(DataChunk &args, ExpressionState &, Vector &result) { + EnsureMeosThreadInitialized(); + BinaryExecutor::Execute(args.data[0], args.data[1], result, args.size(), + [&](string_t in, uint64_t a2) { + Span *s = BlobToSpan(in); + uint64_t r = span_hash_extended(s, a2); + free(s); + return r; + }); +} + static void Gen_span_lower_inc(DataChunk &args, ExpressionState &, Vector &result) { EnsureMeosThreadInitialized(); UnaryExecutor::Execute(args.data[0], result, args.size(), @@ -6831,6 +6853,17 @@ static void Gen_spanset_hash(DataChunk &args, ExpressionState &, Vector &result) }); } +static void Gen_spanset_hash_extended(DataChunk &args, ExpressionState &, Vector &result) { + EnsureMeosThreadInitialized(); + BinaryExecutor::Execute(args.data[0], args.data[1], result, args.size(), + [&](string_t in, uint64_t a2) { + SpanSet *s = BlobToSpanSet(in); + uint64_t r = spanset_hash_extended(s, a2); + free(s); + return r; + }); +} + static void Gen_spanset_lower_inc(DataChunk &args, ExpressionState &, Vector &result) { EnsureMeosThreadInitialized(); UnaryExecutor::Execute(args.data[0], result, args.size(), @@ -17523,6 +17556,7 @@ static void RegisterGenerated_meos_quadbin_conversion(ExtensionLoader &loader) { static void RegisterGenerated_meos_setspan_accessor(ExtensionLoader &loader) { for (auto &type : SetTypes::AllTypes()) { RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {type}, LogicalType::UINTEGER, Gen_set_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {type, LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_set_hash_extended)); RegisterSerializedScalarFunction(loader, ScalarFunction("numValues", {type}, LogicalType::INTEGER, Gen_set_num_values)); } RegisterSerializedScalarFunction(loader, ScalarFunction("endValue", {SetTypes::bigintset()}, LogicalType::BIGINT, Gen_bigintset_end_value)); @@ -17545,6 +17579,7 @@ static void RegisterGenerated_meos_setspan_accessor(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("getValues", {SetTypes::tstzset()}, LogicalType::LIST(LogicalType::TIMESTAMP_TZ), Gen_tstzset_values)); for (auto &type : SpanTypes::AllTypes()) { RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {type}, LogicalType::UINTEGER, Gen_span_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {type, LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_span_hash_extended)); RegisterSerializedScalarFunction(loader, ScalarFunction("lower_inc", {type}, LogicalType::BOOLEAN, Gen_span_lower_inc)); RegisterSerializedScalarFunction(loader, ScalarFunction("lower_inc", {type}, LogicalType::BOOLEAN, Gen_span_upper_inc)); } @@ -17583,6 +17618,7 @@ static void RegisterGenerated_meos_setspan_accessor(ExtensionLoader &loader) { RegisterSerializedScalarFunction(loader, ScalarFunction("upper", {SpansetTypes::tstzspanset()}, LogicalType::TIMESTAMP_TZ, Gen_tstzspanset_upper)); for (auto &type : SpansetTypes::AllTypes()) { RegisterSerializedScalarFunction(loader, ScalarFunction("hash", {type}, LogicalType::UINTEGER, Gen_spanset_hash)); + RegisterSerializedScalarFunction(loader, ScalarFunction("hashExtended", {type, LogicalType::UBIGINT}, LogicalType::UBIGINT, Gen_spanset_hash_extended)); RegisterSerializedScalarFunction(loader, ScalarFunction("lower_inc", {type}, LogicalType::BOOLEAN, Gen_spanset_lower_inc)); RegisterSerializedScalarFunction(loader, ScalarFunction("numSpans", {type}, LogicalType::INTEGER, Gen_spanset_num_spans)); RegisterSerializedScalarFunction(loader, ScalarFunction("lower_inc", {type}, LogicalType::BOOLEAN, Gen_spanset_upper_inc)); diff --git a/src/include/temporal/set_functions.hpp b/src/include/temporal/set_functions.hpp index 3182e020..e563e26d 100644 --- a/src/include/temporal/set_functions.hpp +++ b/src/include/temporal/set_functions.hpp @@ -39,8 +39,6 @@ struct SetFunctions { static void Dateset_to_tstzset(DataChunk &args, ExpressionState &state, Vector &result); static void Tstzset_to_dateset(DataChunk &args, ExpressionState &state, Vector &result); static void Set_mem_size(DataChunk &args, ExpressionState &state, Vector &result); - static void Set_hash(DataChunk &args, ExpressionState &state, Vector &result); - static void Set_hash_extended(DataChunk &args, ExpressionState &state, Vector &result); static void Set_num_values(DataChunk &args, ExpressionState &state, Vector &result); static void Set_start_value(DataChunk &args, ExpressionState &state, Vector &result); static void Set_end_value(DataChunk &args, ExpressionState &state, Vector &result); diff --git a/src/include/temporal/span_functions.hpp b/src/include/temporal/span_functions.hpp index 63da4df4..369ee6f1 100644 --- a/src/include/temporal/span_functions.hpp +++ b/src/include/temporal/span_functions.hpp @@ -48,8 +48,6 @@ struct SpanFunctions { // accessors static void Span_lower(DataChunk &args, ExpressionState &state, Vector &result); static void Span_upper(DataChunk &args, ExpressionState &state, Vector &result); - static void Span_hash(DataChunk &args, ExpressionState &state, Vector &result); - static void Span_hash_extended(DataChunk &args, ExpressionState &state, Vector &result); static void Span_lower_inc(DataChunk &args, ExpressionState &state, Vector &result); static void Span_upper_inc(DataChunk &args, ExpressionState &state, Vector &result); static void Numspan_width(DataChunk &args, ExpressionState &state, Vector &result); diff --git a/src/include/temporal/spanset_functions.hpp b/src/include/temporal/spanset_functions.hpp index ec210fc9..a88a69b9 100644 --- a/src/include/temporal/spanset_functions.hpp +++ b/src/include/temporal/spanset_functions.hpp @@ -49,8 +49,6 @@ struct SpansetFunctions{ static void Spanset_mem_size(DataChunk &args, ExpressionState &state, Vector &result); static void Spanset_lower(DataChunk &args, ExpressionState &state, Vector &result); static void Spanset_upper(DataChunk &args, ExpressionState &state, Vector &result); - static void Spanset_hash(DataChunk &args, ExpressionState &state, Vector &result); - static void Spanset_hash_extended(DataChunk &args, ExpressionState &state, Vector &result); static void Spanset_lower_inc(DataChunk &args, ExpressionState &state, Vector &result); static void Spanset_upper_inc(DataChunk &args, ExpressionState &state, Vector &result); static void Numspanset_width(DataChunk &args, ExpressionState &state, Vector &result); diff --git a/src/temporal/set.cpp b/src/temporal/set.cpp index ee12b87f..47335a01 100644 --- a/src/temporal/set.cpp +++ b/src/temporal/set.cpp @@ -121,13 +121,8 @@ void SetTypes::RegisterScalarFunctions(ExtensionLoader &loader) { ScalarFunction("memSize",{set_type}, LogicalType::INTEGER, SetFunctions::Set_mem_size) ); - duckdb::RegisterSerializedScalarFunction(loader, - ScalarFunction("set_hash", {set_type}, LogicalType::UINTEGER, SetFunctions::Set_hash) - ); - - duckdb::RegisterSerializedScalarFunction(loader, - ScalarFunction("set_hash_extended", {set_type, LogicalType::BIGINT}, LogicalType::UBIGINT, SetFunctions::Set_hash_extended) - ); + // hash(set_type) / hashExtended(set_type, UBIGINT) are generated from the + // catalog (meos_setspan_accessor) in generated_temporal_udfs.cpp. // numValues / startValue / endValue on set types are generated from the // catalog (meos_setspan_accessor) in generated_temporal_udfs.cpp. diff --git a/src/temporal/set_functions.cpp b/src/temporal/set_functions.cpp index 8964808b..f4cfc09d 100644 --- a/src/temporal/set_functions.cpp +++ b/src/temporal/set_functions.cpp @@ -541,38 +541,6 @@ void SetFunctions::Set_mem_size(DataChunk &args, ExpressionState &state, Vector }); } -// --- set_hash / set_hash_extended --- -void SetFunctions::Set_hash(DataChunk &args, ExpressionState &state, Vector &result) { - auto &input = args.data[0]; - UnaryExecutor::Execute( - input, result, args.size(), - [&](string_t input_blob) -> uint32_t { - const uint8_t *data = (const uint8_t *)input_blob.GetData(); - size_t size = input_blob.GetSize(); - Set *s = (Set*)malloc(size); - memcpy(s, data, size); - uint32_t h = set_hash(s); - free(s); - return h; - }); -} - -void SetFunctions::Set_hash_extended(DataChunk &args, ExpressionState &state, Vector &result) { - auto &input = args.data[0]; - auto &seed_vec = args.data[1]; - BinaryExecutor::Execute( - input, seed_vec, result, args.size(), - [&](string_t input_blob, int64_t seed) -> uint64_t { - const uint8_t *data = (const uint8_t *)input_blob.GetData(); - size_t size = input_blob.GetSize(); - Set *s = (Set*)malloc(size); - memcpy(s, data, size); - uint64_t h = set_hash_extended(s, (uint64_t)seed); - free(s); - return h; - }); -} - // --- numValue --- void SetFunctions::Set_num_values(DataChunk &args, ExpressionState &state, Vector &result) { auto &input = args.data[0]; diff --git a/src/temporal/span.cpp b/src/temporal/span.cpp index 33a57a8b..1b805b4a 100644 --- a/src/temporal/span.cpp +++ b/src/temporal/span.cpp @@ -239,8 +239,8 @@ void SpanTypes::RegisterScalarFunctions(ExtensionLoader &loader) { duckdb::RegisterSerializedScalarFunction(loader, ScalarFunction("lowerInc",{span_type}, LogicalType::BOOLEAN, SpanFunctions::Span_lower_inc)); duckdb::RegisterSerializedScalarFunction(loader, ScalarFunction("upperInc",{span_type}, LogicalType::BOOLEAN, SpanFunctions::Span_upper_inc)); - duckdb::RegisterSerializedScalarFunction(loader, ScalarFunction("span_hash", {span_type}, LogicalType::UINTEGER, SpanFunctions::Span_hash)); - duckdb::RegisterSerializedScalarFunction(loader, ScalarFunction("span_hash_extended", {span_type, LogicalType::BIGINT}, LogicalType::UBIGINT, SpanFunctions::Span_hash_extended)); + // hash(span_type) / hashExtended(span_type, UBIGINT) are generated from the + // catalog (meos_setspan_accessor) in generated_temporal_udfs.cpp. } // expand(intspan/bigintspan/floatspan, ) is generated from the catalog diff --git a/src/temporal/span_functions.cpp b/src/temporal/span_functions.cpp index 50a5dac0..b3884235 100644 --- a/src/temporal/span_functions.cpp +++ b/src/temporal/span_functions.cpp @@ -861,37 +861,6 @@ void SpanFunctions::Span_upper(DataChunk &args, ExpressionState &state, Vector & } } -void SpanFunctions::Span_hash(DataChunk &args, ExpressionState &state, Vector &result) { - auto &input = args.data[0]; - UnaryExecutor::Execute( - input, result, args.size(), - [&](string_t input_blob) -> uint32_t { - const uint8_t *data = (const uint8_t *)input_blob.GetData(); - size_t size = input_blob.GetSize(); - Span *s = (Span*)malloc(size); - memcpy(s, data, size); - uint32_t h = span_hash(s); - free(s); - return h; - }); -} - -void SpanFunctions::Span_hash_extended(DataChunk &args, ExpressionState &state, Vector &result) { - auto &input = args.data[0]; - auto &seed_vec = args.data[1]; - BinaryExecutor::Execute( - input, seed_vec, result, args.size(), - [&](string_t input_blob, int64_t seed) -> uint64_t { - const uint8_t *data = (const uint8_t *)input_blob.GetData(); - size_t size = input_blob.GetSize(); - Span *s = (Span*)malloc(size); - memcpy(s, data, size); - uint64_t h = span_hash_extended(s, (uint64_t)seed); - free(s); - return h; - }); -} - void SpanFunctions::Span_lower_inc(DataChunk &args, ExpressionState &state, Vector &result) { auto &input = args.data[0]; auto span_type = SpanTypeMapping::GetMeosTypeFromAlias(input.GetType().ToString()); diff --git a/src/temporal/spanset.cpp b/src/temporal/spanset.cpp index e5ab7c40..7ffc434c 100644 --- a/src/temporal/spanset.cpp +++ b/src/temporal/spanset.cpp @@ -262,13 +262,8 @@ void SpansetTypes::RegisterScalarFunctions(ExtensionLoader &loader) { ScalarFunction("splitEachNspans", {spanset_type, LogicalType::INTEGER}, LogicalType::LIST(child_type), SpansetFunctions::Spanset_split_each_n_spans) ); - // Hash - duckdb::RegisterSerializedScalarFunction(loader, - ScalarFunction("spanset_hash", {spanset_type}, LogicalType::UINTEGER, SpansetFunctions::Spanset_hash) - ); - duckdb::RegisterSerializedScalarFunction(loader, - ScalarFunction("spanset_hash_extended", {spanset_type, LogicalType::BIGINT}, LogicalType::UBIGINT, SpansetFunctions::Spanset_hash_extended) - ); + // hash(spanset_type) / hashExtended(spanset_type, UBIGINT) are generated from + // the catalog (meos_setspan_accessor) in generated_temporal_udfs.cpp. // comparison operators duckdb::RegisterSerializedScalarFunction(loader, diff --git a/src/temporal/spanset_functions.cpp b/src/temporal/spanset_functions.cpp index d6785e6d..a38528e1 100644 --- a/src/temporal/spanset_functions.cpp +++ b/src/temporal/spanset_functions.cpp @@ -742,39 +742,6 @@ void SpansetFunctions::Spanset_upper(DataChunk &args, ExpressionState &state, Ve } } -// --- spanset_hash / spanset_hash_extended --- - -void SpansetFunctions::Spanset_hash(DataChunk &args, ExpressionState &state, Vector &result) { - auto &input = args.data[0]; - UnaryExecutor::Execute( - input, result, args.size(), - [&](string_t input_blob) -> uint32_t { - const uint8_t *data = (const uint8_t *)input_blob.GetData(); - size_t size = input_blob.GetSize(); - SpanSet *s = (SpanSet*)malloc(size); - memcpy(s, data, size); - uint32_t h = spanset_hash(s); - free(s); - return h; - }); -} - -void SpansetFunctions::Spanset_hash_extended(DataChunk &args, ExpressionState &state, Vector &result) { - auto &input = args.data[0]; - auto &seed_vec = args.data[1]; - BinaryExecutor::Execute( - input, seed_vec, result, args.size(), - [&](string_t input_blob, int64_t seed) -> uint64_t { - const uint8_t *data = (const uint8_t *)input_blob.GetData(); - size_t size = input_blob.GetSize(); - SpanSet *s = (SpanSet*)malloc(size); - memcpy(s, data, size); - uint64_t h = spanset_hash_extended(s, (uint64_t)seed); - free(s); - return h; - }); -} - // --- lower_inc --- void SpansetFunctions::Spanset_lower_inc(DataChunk &args, ExpressionState &state, Vector &result) { diff --git a/test/sql/parity/001_set.test b/test/sql/parity/001_set.test index b517e498..d582ddc1 100644 --- a/test/sql/parity/001_set.test +++ b/test/sql/parity/001_set.test @@ -483,49 +483,51 @@ SELECT tstzset '{2000-01-01}' >= tstzset '{2000-01-01, 2000-01-02, 2000-01-03}'; ---- false -mode skip -# set_hash / set_hash_extended not registered. MEOS symbols: -# set_hash, set_hash_extended. +# hash / hashExtended over set types. hash (uint32 -> UINTEGER) and +# hashExtended (uint64 + seed -> UBIGINT); the extended form is generated +# from the catalog (meos_setspan_accessor) with the canonical bare name. query I -SELECT set_hash(dateset '{2000-01-01,2000-01-02}') = set_hash(dateset '{2000-01-01,2000-01-02}'); +SELECT hash(dateset '{2000-01-01,2000-01-02}') = hash(dateset '{2000-01-01,2000-01-02}'); ---- true query I -SELECT set_hash(dateset '{2000-01-01,2000-01-02}') <> set_hash(dateset '{2000-01-01,2000-01-02}'); +SELECT hash(dateset '{2000-01-01,2000-01-02}') <> hash(dateset '{2000-01-01,2000-01-02}'); ---- false query I -SELECT set_hash(tstzset '{2000-01-01,2000-01-02}') = set_hash(tstzset '{2000-01-01,2000-01-02}'); +SELECT hash(tstzset '{2000-01-01,2000-01-02}') = hash(tstzset '{2000-01-01,2000-01-02}'); ---- true query I -SELECT set_hash(tstzset '{2000-01-01,2000-01-02}') <> set_hash(tstzset '{2000-01-01,2000-01-02}'); +SELECT hash(tstzset '{2000-01-01,2000-01-02}') <> hash(tstzset '{2000-01-01,2000-01-02}'); ---- false query I -SELECT set_hash_extended(dateset '{2000-01-01,2000-01-02}', 1) = set_hash_extended(dateset '{2000-01-01,2000-01-02}', 1); +SELECT hashExtended(dateset '{2000-01-01,2000-01-02}', 1) = hashExtended(dateset '{2000-01-01,2000-01-02}', 1); ---- true query I -SELECT set_hash_extended(dateset '{2000-01-01,2000-01-02}', 1) <> set_hash_extended(dateset '{2000-01-01,2000-01-02}', 1); +SELECT hashExtended(dateset '{2000-01-01,2000-01-02}', 1) <> hashExtended(dateset '{2000-01-01,2000-01-02}', 1); ---- false query I -SELECT set_hash_extended(tstzset '{2000-01-01,2000-01-02}', 1) = set_hash_extended(tstzset '{2000-01-01,2000-01-02}', 1); +SELECT hashExtended(tstzset '{2000-01-01,2000-01-02}', 1) = hashExtended(tstzset '{2000-01-01,2000-01-02}', 1); ---- true query I -SELECT set_hash_extended(tstzset '{2000-01-01,2000-01-02}', 1) <> set_hash_extended(tstzset '{2000-01-01,2000-01-02}', 1); +SELECT hashExtended(tstzset '{2000-01-01,2000-01-02}', 1) <> hashExtended(tstzset '{2000-01-01,2000-01-02}', 1); ---- false +mode skip + # ============================================================================= # Transformations # ============================================================================= diff --git a/test/sql/parity/003_span.test b/test/sql/parity/003_span.test index 09b031c2..ae2d2c84 100644 --- a/test/sql/parity/003_span.test +++ b/test/sql/parity/003_span.test @@ -299,22 +299,22 @@ SELECT ge(tstzspan '[2000-01-01,2000-01-01]', tstzspan '(2000-01-01,2000-01-02)' false query I -SELECT span_hash(tstzspan '[2000-01-01,2000-01-02]') = span_hash(tstzspan '[2000-01-01,2000-01-02]'); +SELECT hash(tstzspan '[2000-01-01,2000-01-02]') = hash(tstzspan '[2000-01-01,2000-01-02]'); ---- true query I -SELECT span_hash(tstzspan '[2000-01-01,2000-01-02]') <> span_hash(tstzspan '[2000-01-02,2000-01-02]'); +SELECT hash(tstzspan '[2000-01-01,2000-01-02]') <> hash(tstzspan '[2000-01-02,2000-01-02]'); ---- true query I -SELECT span_hash_extended(tstzspan '[2000-01-01,2000-01-02]', 1) = span_hash_extended(tstzspan '[2000-01-01,2000-01-02]', 1); +SELECT hashExtended(tstzspan '[2000-01-01,2000-01-02]', 1) = hashExtended(tstzspan '[2000-01-01,2000-01-02]', 1); ---- true query I -SELECT span_hash_extended(tstzspan '[2000-01-01,2000-01-02]', 1) <> span_hash_extended(tstzspan '[2000-01-02,2000-01-02]', 1); +SELECT hashExtended(tstzspan '[2000-01-01,2000-01-02]', 1) <> hashExtended(tstzspan '[2000-01-02,2000-01-02]', 1); ---- true diff --git a/test/sql/parity/007_spanset.test b/test/sql/parity/007_spanset.test index 49876cce..173158df 100644 --- a/test/sql/parity/007_spanset.test +++ b/test/sql/parity/007_spanset.test @@ -556,12 +556,12 @@ SELECT intspanset '{[1,1]}' >= intspanset '{[1,2),[2,3),[3,4)}'; false query I -SELECT spanset_hash(intspanset '{[1,2]}') = spanset_hash(intspanset '{[1,2]}'); +SELECT hash(intspanset '{[1,2]}') = hash(intspanset '{[1,2]}'); ---- true query I -SELECT spanset_hash_extended(intspanset '{[1,2]}', 1) = spanset_hash_extended(intspanset '{[1,2]}', 1); +SELECT hashExtended(intspanset '{[1,2]}', 1) = hashExtended(intspanset '{[1,2]}', 1); ---- true diff --git a/test/sql/temporal_hash.test b/test/sql/temporal_hash.test index 27c17ee3..b17b1494 100644 --- a/test/sql/temporal_hash.test +++ b/test/sql/temporal_hash.test @@ -9,35 +9,35 @@ require mobilityduck # temporal_hash returns the uint32 hash as the native UINTEGER query I -SELECT temporal_hash(tint '1@2000-01-01'); +SELECT hash(tint '1@2000-01-01'); ---- 157457912 query I -SELECT typeof(temporal_hash(tint '1@2000-01-01')); +SELECT typeof(hash(tint '1@2000-01-01')); ---- UINTEGER # temporal_hash_extended returns the uint64 hash as the native UBIGINT. This value # (> 2**63) does NOT fit in a signed BIGINT — proof that UBIGINT is required. query I -SELECT temporal_hash_extended(tint '1@2000-01-01', 0); +SELECT hashExtended(tint '1@2000-01-01', 0); ---- 11445401048662056440 query I -SELECT typeof(temporal_hash_extended(tint '1@2000-01-01', 0)); +SELECT typeof(hashExtended(tint '1@2000-01-01', 0)); ---- UBIGINT # the seed changes the hash (0 vs 42) query I -SELECT temporal_hash_extended(tint '1@2000-01-01', 42); +SELECT hashExtended(tint '1@2000-01-01', 42); ---- 10824501823241357556 # inherited over every temporal family via Temporal query I -SELECT temporal_hash_extended(tfloat '1.5@2000-01-01', 42); +SELECT hashExtended(tfloat '1.5@2000-01-01', 42); ---- 17681145013286498633 diff --git a/tools/codegen_duck_udfs.py b/tools/codegen_duck_udfs.py index 71955403..f4c3792d 100644 --- a/tools/codegen_duck_udfs.py +++ b/tools/codegen_duck_udfs.py @@ -708,6 +708,11 @@ def shape_set(f): and not selem(ins[1]) and base(ins[1]["canonical"]) in SCALAR_ARG and "*" not in norm(ins[1]["canonical"]) and set_reg_scope(f["name"])): return ("setcsc:" + base(ins[1]["canonical"]), "LogicalType::BLOB") + # (Set, by-value uint64 seed) -> uint64 hash (set_hash_extended); name-scoped like setcsc. + if (len(ins) == 2 and setp(ins[0]) and base(ins[1]["canonical"]) in SCALAR_ARG + and "*" not in norm(ins[1]["canonical"]) and rb == "uint64_t" and "*" not in rn + and set_reg_scope(f["name"])): + return ("bsc:" + base(ins[1]["canonical"]), "LogicalType::UBIGINT") if set_reg_scope(f["name"]) is None: return None if len(ins) == 1 and setp(ins[0]): if rb == "Set" and rn.endswith("*"): return ("u_set", "LogicalType::BLOB") @@ -760,6 +765,14 @@ def emit_set(f, kind): f" [&](string_t a, {cpp2} a2) {{\n" f" Set *s = BlobToSet(a);\n Set *r = {name}(s, {marsh});\n free(s);\n" f" return SetToBlob(result, r);\n }});\n}}\n") + if kind.startswith("bsc:"): # (Set, by-value uint64 seed) -> uint64 hash (set_hash_extended) + _dt, cpp2, marsh = SCALAR_ARG[kind.split(':')[1]] + return (f"static void Gen_{name}(DataChunk &args, ExpressionState &, Vector &result) {{\n" + f" EnsureMeosThreadInitialized();\n" + f" BinaryExecutor::Execute(args.data[0], args.data[1], result, args.size(),\n" + f" [&](string_t a, {cpp2} a2) {{\n" + f" Set *s = BlobToSet(a);\n uint64_t r = {name}(s, {marsh});\n free(s);\n" + f" return r;\n }});\n}}\n") if kind.startswith("scset:"): # (scalar, Set) -> bool e = kind.split(':')[1] if e == "text": @@ -1987,6 +2000,13 @@ def shape_span(f, C=SPAN_C): and "*" not in norm(ins[1]["canonical"]) and rb == "Interval" and rn.endswith("*") and C["scope"] is not None and C["scope"](f["name"]) is not None): return ("u2iv:" + base(ins[1]["canonical"]), "LogicalType::INTERVAL") + # (X, by-value uint64 seed) -> uint64 hash (span_hash_extended/spanset_hash_extended); + # scope-gated like u2iv. Boxes (STBOX_C/TBOX_C, scope=None) are excluded — their + # hash_extended stays hand-registered until their own wave. + if (contp(ins[0]) and base(ins[1]["canonical"]) in SCALAR_ARG + and "*" not in norm(ins[1]["canonical"]) and rb == "uint64_t" and "*" not in rn + and C["scope"] is not None and C["scope"](f["name"]) is not None): + return ("bsc:" + base(ins[1]["canonical"]), "LogicalType::UBIGINT") # (X, scalar PARAM) -> X : a same-container return whose scalar is NOT an element # (floatspan_round/floatspanset_round's precision integer). Name-scoped (span_round # -> that container type), so the round=float-only base-value scoping falls out. @@ -2064,6 +2084,14 @@ def emit_span(f, kind, C=SPAN_C): f" [&](string_t in, {cpp2} a2) {{\n" f" {cb} *s = {bt}(in);\n MeosInterval *r = {name}(s, {marsh});\n free(s);\n" f" return TakeInterval(r);\n }});\n}}\n") + if kind.startswith("bsc:"): # (X, by-value uint64 seed) -> uint64 hash (X_hash_extended) + _dt, cpp2, marsh = SCALAR_ARG[kind.split(':')[1]] + return (f"static void Gen_{name}(DataChunk &args, ExpressionState &, Vector &result) {{\n" + f" EnsureMeosThreadInitialized();\n" + f" BinaryExecutor::Execute(args.data[0], args.data[1], result, args.size(),\n" + f" [&](string_t in, {cpp2} a2) {{\n" + f" {cb} *s = {bt}(in);\n uint64_t r = {name}(s, {marsh});\n free(s);\n" + f" return r;\n }});\n}}\n") if kind.startswith("csc:"): # (X, by-value scalar param) -> X (round(floatspan, integer)) _dt, cpp2, marsh = SCALAR_ARG[kind.split(':')[1]] return (f"static void Gen_{name}(DataChunk &args, ExpressionState &, Vector &result) {{\n" @@ -2912,6 +2940,19 @@ def gen_cpp(fns, out_path, declared=None, aliases=None): set_specific_regs.append(f' RegisterSerializedScalarFunction(loader, ScalarFunction(' f'"{reg_name(nm, f)}", {sig}, LogicalType::BOOLEAN, Gen_{fn}));') continue + if kind.startswith("bsc:"): # (Set, by-value uint64 seed) -> uint64 hash: name-scoped 2-arg {type, UBIGINT} + argdt = SCALAR_ARG[kind.split(':')[1]][0] + scope, accs = set_reg_scope(fn) + if scope == "all": + for nm in names: + set_generic_regs.append(f' RegisterSerializedScalarFunction(loader, ScalarFunction(' + f'"{reg_name(nm, f)}", {{type, {argdt}}}, {dret}, Gen_{fn}));') + else: + for a in accs: + for nm in names: + set_specific_regs.append(f' RegisterSerializedScalarFunction(loader, ScalarFunction(' + f'"{reg_name(nm, f)}", {{{a}, {argdt}}}, {dret}, Gen_{fn}));') + continue sc = set_reg_scope(fn) scope, accs = sc if sc else ("all", None) # b_set/b_bool (_set_set) -> over AllTypes nargs = len(classify(f)[0]) @@ -2998,6 +3039,20 @@ def gen_cpp(fns, out_path, declared=None, aliases=None): span_specific_regs.append(f' RegisterSerializedScalarFunction(loader, ScalarFunction(' f'"{reg_name(nm, f)}", {{{a}, {argdt}}}, {dret}, Gen_{fn}));') continue + # (X, by-value uint64 seed)->uint64 hash: name-scoped, 2-arg sig {acc, UBIGINT}. + if kind.startswith("bsc:"): + argdt = SCALAR_ARG[kind.split(':')[1]][0] + scope, accs = C["scope"](fn) + if scope == "all": + for nm in names: + gen.append(f' RegisterSerializedScalarFunction(loader, ScalarFunction(' + f'"{reg_name(nm, f)}", {{type, {argdt}}}, {dret}, Gen_{fn}));') + else: + for a in accs: + for nm in names: + span_specific_regs.append(f' RegisterSerializedScalarFunction(loader, ScalarFunction(' + f'"{reg_name(nm, f)}", {{{a}, {argdt}}}, {dret}, Gen_{fn}));') + continue # (X, scalar PARAM)->X: floatspan(set)_round. Name-scoped 2-arg {X, argtype}->X; # plus the shorter {X}->X overload when the trailing scalar has a SQL default. if kind.startswith("csc:"):