Repository navigation
Answer NULL at the distance sentinel the catalog states through distance_sentinel - #426
Merged
estebanzimanyi merged 1 commit intoOct 5, 2026
Conversation
…nce_sentinel
tools/codegen_duck_udfs.py reads the guard if (datum_eq(result, distance_sentinel(basetype),
basetype)), on which a PG wrapper returns NULL for a distance computed in the base type, as the
test r == std::numeric_limits<decltype(r)>::max() on the result in the type MEOS returns, before
its conversion to the declared float, as emit_temporal_box tests the sentinel of a box. The
nearest approach distance between two temporal numbers, and between a temporal number and a
number, is NULL where the two share no time, over tint, tbigint and tfloat.
Why: distance_sentinel answers the maximum of the type the distance is expressed in where no
distance is computed, and NAD_tnumber_tnumber and NAD_tnumber_number return NULL on it; the
catalog carries that guard in shape.nullableResult, while SCALAR_NULL_GUARD read only the
result == DBL_MAX form, so the six nearestApproachDistance functions over numbers returned the
sentinel itself as a distance.
Witness: Gen_nad_tfloat_tfloat returns (double) r with no test, r being what nad_tfloat_tfloat
answers, so for two tfloat values sharing no time the row holds DBL_MAX, and over tint and
tbigint the maxima of int and int64 widened to a double; with this change the row is NULL.
Measured: over the catalog the shared provision derives from MobilityDB master 4c4457d2ec, the
generator writes the same 1972 functions and 7389 registrations, and the six
Gen_nad_{tint_int, tint_tint, tbigint_bigint, tbigint_tbigint, tfloat_float, tfloat_tfloat}
take ExecuteWithNulls and the test; no other function differs. The committed surface carries the
six as the generator writes them; generated_temporal_udfs_2.cpp compiles warning-free.
test/sql/parity/036_tnumber_distance.test states the three NULLs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tools/codegen_duck_udfs.py reads the guard if (datum_eq(result, distance_sentinel(basetype),
basetype)), on which a PG wrapper returns NULL for a distance computed in the base type, as the
test r == std::numeric_limits<decltype(r)>::max() on the result in the type MEOS returns, before
its conversion to the declared float, as emit_temporal_box tests the sentinel of a box. The
nearest approach distance between two temporal numbers, and between a temporal number and a
number, is NULL where the two share no time, over tint, tbigint and tfloat.
Why: distance_sentinel answers the maximum of the type the distance is expressed in where no
distance is computed, and NAD_tnumber_tnumber and NAD_tnumber_number return NULL on it; the
catalog carries that guard in shape.nullableResult, while SCALAR_NULL_GUARD read only the
result == DBL_MAX form, so the six nearestApproachDistance functions over numbers returned the
sentinel itself as a distance.
Witness: Gen_nad_tfloat_tfloat returns (double) r with no test, r being what nad_tfloat_tfloat
answers, so for two tfloat values sharing no time the row holds DBL_MAX, and over tint and
tbigint the maxima of int and int64 widened to a double; with this change the row is NULL.
Measured: over the catalog the shared provision derives from MobilityDB master 4c4457d2ec, the
generator writes the same 1972 functions and 7389 registrations, and the six
Gen_nad_{tint_int, tint_tint, tbigint_bigint, tbigint_tbigint, tfloat_float, tfloat_tfloat}
take ExecuteWithNulls and the test; no other function differs. The committed surface carries the
six as the generator writes them; generated_temporal_udfs_2.cpp compiles warning-free.
test/sql/parity/036_tnumber_distance.test states the three NULLs.