@terascope/data-mate / teal-frame/plain-values
teal-frame/plain-values
Variables
MAX_SAFE_BIGINT
constMAX_SAFE_BIGINT:9007199254740991n=9007199254740991n
Defined in: data-mate/src/teal-frame/plain-values.ts:28
Converts values read from DuckDB into the plain JS values rows() returns.
rows() results are sent straight to callers, so no DuckDB value class may leak through:
- LIST arrives as a
DuckDBListValue, which would serialize as{"items":[...]}. It becomes an array. - TIMESTAMP arrives as a
DuckDBTimestampValue. It is rendered withtoISO8601, asDateVector.toJSONCompatibleValuedoes. - GEOMETRY arrives as WKB bytes. It is decoded back to the GeoShape a
GeoJSONfield holds. - BIGINT and HUGEINT arrive as a JS
bigint, whichJSON.stringifycannot serialize.bigIntToPlainreturns a number when the value fits exactly and a decimal string otherwise.
core-utils' bigIntToJSON is not used, because it is wrong for values read from DuckDB
(#4555). It subtracts 1 from every positive value above the safe limit, to cancel a +1 that
core-utils' parser adds, so a value that was never parsed comes back one too low. Its bound
is also a signed comparison, so large negative values lose precision instead of becoming
strings.
The rule here is the same as in export-json.ts (abs(value) > MAX_SAFE becomes a decimal
string, anything smaller a number), so rows() and ndjson() always agree.
Functions
parseJSONText()
parseJSONText(
value):unknown
Defined in: data-mate/src/teal-frame/plain-values.ts:74
Parses a JSON column's text into the value it encodes. Any and untyped Object fields are
stored as DuckDB JSON columns, which DuckDB returns as text.
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
unknown
toPlainValue()
toPlainValue(
value):unknown
Defined in: data-mate/src/teal-frame/plain-values.ts:42
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
unknown