Class VariantJsonText
SELECT ARRAY_CONSTRUCT(1.0::FLOAT) [1.000000000000000e+00] the display SELECT TO_JSON(ARRAY_CONSTRUCT(1.0::FLOAT)) [1.000000000000000e+00] the conversion
★ THE FAMILY DECIDES, NOT THE VALUE. A DECIMAL and an INTEGER convert exactly as they display —
[1.5] stays [1.5] and [1] stays [1] — so this is one family's own
rule rather than a number format. The family is read off the parsed node (isFloatingPointNumber),
because the canonical TEXT has already been normalised and no longer says which notation it was
written in.
★ THE FORM IS %.15e, measured part by part: one digit, a point, FIFTEEN decimals, a
lower-case e, an explicit sign, and an exponent of at least two digits that widens rather
than truncating — 1e100 is 1.000000000000000e+100 and 1e308 keeps all three.
A negative zero keeps its sign (-0.000000000000000e+00).
★ THE SURFACES THAT USE IT are the conversions — TO_JSON, ::VARCHAR and TO_VARCHAR — and
the display: the cell a client reads through the driver or the HTTP wire, a whole value or a member
alike, and the engine's own display of a container. The one exception is a bare DOUBLE under the
STRING conversions, which takes a FLOAT's text instead (see stringConversionTextOf(java.lang.Object)). HASH's
canonical value keeps the canonical text, and CONCAT and LISTAGG refuse a container outright.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringclientTextOf(VariantValue value) The JSON text a client reads for a semi-structured value:displayTextOf(dev.frostlake.values.VariantValue), or the canonical text when there is no DOUBLE in it.static StringconvertedTextOf(Object value) The conversion text of a semi-structured value, or null when the value is not one.static StringdisplayTextOf(VariantValue value) The JSON text a client reads for a semi-structured value, or null when it holds no DOUBLE and the canonical text already is that text.static StringdoubleText(double value) One DOUBLE in the form the conversion uses:%.15eas C prints it, rounded from the double's exact binary value.static booleanisSemiStructured(DataType declared) Whether a column's declared type is one whose cells a client reads as JSON text.static Stringrender(tools.jackson.databind.JsonNode node) One node's conversion text.static StringstringConversionTextOf(Object value) The text of a semi-structured value under the STRING conversions —::VARCHAR, TO_VARCHAR, TO_CHAR — which differs from TO_JSON's in one place: a value that IS a double and nothing more converts to a FLOAT's text rather than the fifteen-decimal one (live-verified cell by cell).static StringunwrappedDoubleText(Object value, DataType declared) The client text of a DOUBLE read out of a semi-structured value, or null whenvalueis not one.static StringunwrappedStringText(String value) The client text of a STRING read out of a semi-structured value: its JSON text, quotes included, as the account's driver hands every VARIANT cell back ("v"forOBJECT_CONSTRUCT('k', 'v'):k).
-
Method Details
-
convertedTextOf
The conversion text of a semi-structured value, or null when the value is not one.- Parameters:
value- any runtime value- Returns:
- the JSON text live converts it to, or null when this rule does not apply
-
displayTextOf
The JSON text a client reads for a semi-structured value, or null when it holds no DOUBLE and the canonical text already is that text. Every DOUBLE takes the conversion form, a whole value as much as a member: live displaysTO_VARIANT(1.5::FLOAT)as1.500000000000000e+00andARRAY_CONSTRUCT(1.0::FLOAT)as[1.000000000000000e+00]. A VECTOR keeps its own text, since no display of one inside a VARIANT has been measured.- Parameters:
value- the value- Returns:
- its display JSON text, or null when that is the canonical text
-
clientTextOf
The JSON text a client reads for a semi-structured value:displayTextOf(dev.frostlake.values.VariantValue), or the canonical text when there is no DOUBLE in it.- Parameters:
value- the value- Returns:
- its client JSON text
-
unwrappedDoubleText
The client text of a DOUBLE read out of a semi-structured value, or null whenvalueis not one. An element or a path result arrives unwrapped, a Double under its VARIANT column, and the account still spells it as the VARIANT it is: the fifteen-decimal form, a non-finite value as its bare word.- Parameters:
value- any runtime valuedeclared- the column's declared type- Returns:
- its client text, or null when this rule does not apply
-
isSemiStructured
Whether a column's declared type is one whose cells a client reads as JSON text. -
unwrappedStringText
The client text of a STRING read out of a semi-structured value: its JSON text, quotes included, as the account's driver hands every VARIANT cell back ("v"forOBJECT_CONSTRUCT('k', 'v'):k). The engine carries a JSON null unwrapped as the bare textnull, and a string whose content could pass for structure or for that null already in its quotes; both are their own JSON text.- Parameters:
value- an unwrapped string under a semi-structured column- Returns:
- its JSON text
-
stringConversionTextOf
The text of a semi-structured value under the STRING conversions —::VARCHAR, TO_VARCHAR, TO_CHAR — which differs from TO_JSON's in one place: a value that IS a double and nothing more converts to a FLOAT's text rather than the fifteen-decimal one (live-verified cell by cell). A double that came from a FLOAT through TO_VARIANT takes the shortest round-trip form held to ten significant digits and one more per decade (1.5,3.0,1.0E18,-0.0,1.414213562for SQRT(2)); a double read from JSON text takes the FLOAT text (100for1e2,1e+18,1e-07,-0). A double INSIDE a container stays in the conversion form ([1.500000000000000e+00]), as does TO_JSON of the bare double.- Parameters:
value- any runtime value- Returns:
- the text, or null when the value is not semi-structured or needs no rewriting
-
render
One node's conversion text.- Parameters:
node- the parsed document- Returns:
- its JSON text with every DOUBLE rewritten
-
doubleText
One DOUBLE in the form the conversion uses:%.15eas C prints it, rounded from the double's exact binary value. Java's formatter pads the shortest decimal representation instead, which differs wherever that representation is shorter than the value's sixteen digits: the smallest subnormal, 4.9E-324, is4.940656458412465e-324on the account.- Parameters:
value- the double- Returns:
- its fifteen-decimal scientific text
-