Check numeric text contracts before changing a DuckDB UNION
A UNION change can affect serialized numeric text as well as duplicate counts.
Numeric meaning and text identity
Fix the serialized-value contract before approving a change in duplicate handling. Although 87 and 87.0 denote the same number mathematically, they are different text keys, signatures and comparison values. Truthound does not choose the preferred representation; it checks a representation policy that has already been selected. [1, 2, 3]
The reported nested-UNION difference
The public DuckDB issue shows an inner UNION resolving numeric types before an outer string branch is introduced. The form of the outer operation changes how an integer is rendered as text. The reporter also asks about the intended coercion semantics. Treat this as a migration question to verify, rather than an independently established standards violation. [1]
Record each branch's type
Specify intermediate types and final text representations, then compare both value sets and duplicate-removal results. Equal row counts can hide a different surviving string. Conversely, formatting the output afterwards may not restore rows already removed by a different equality decision. [1, 3]
The expected representation is a policy
In an illustrative policy, the approved text for numeric 87 is 87.0. Serialized numeric text 87.0 preserves the approved representation; text 87 violates that representation contract. That failure identifies a serialization-contract violation, not a change in the mathematical number. A system requiring integer-style text could select the opposite policy, but should not silently mix both policies in one batch. [1, 3]
Validate allowed meaning–representation pairs
Truthound Core's ColumnPairInSetValidator can receive approved pairs of normalized numeric meaning and serialized text to detect an unexpected coercion path. Preserve the raw text and specify NULL handling separately. An alternative is to cast every UNION branch explicitly to the same target type. The validator does not decide which type-coercion semantics parentheses should imply. [1, 2, 3]
Application conditions
Link each union_variant and its intermediate type and canonical_numeric_text to the source value. Approve numeric-meaning and text pairs before execution.
Alternatives
Explicitly cast numeric values in every UNION branch to the approved common type.
Limitations
Truthound does not decide intended type-coercion semantics from parentheses. The user must choose the allowed representation policy.
Evidence
- Event checked
- Subject checked
- Modified
