Skip to content

Weight

Type Registry

Weight

identity.person.weight

Person weight in kg, lbs, or other units (e.g., 75kg, 165lbs). Transforms to DOUBLE (kilograms). Decompose extracts value and unit.

Domain identityperson
Casts to DOUBLE
Scope Universal

Try it

CLI
$ finetype infer -i "75 kg"
→ identity.person.weight

DuckDB

Detect
SELECT finetype('75 kg');
-- → 'identity.person.weight'
Cast expression
CASE
  WHEN UPPER({col}) LIKE '%LB%' THEN CAST(REGEXP_EXTRACT({col}, '^([0-9.]+)') AS DOUBLE) / 2.20462
  ELSE CAST(REGEXP_EXTRACT({col}, '^([0-9.]+)') AS DOUBLE)
END
Safe cast pipeline
-- Normalise and cast in one step
SELECT TRY_CAST(finetype_cast(my_column) AS DOUBLE) AS clean_value
FROM my_table
WHERE finetype(my_column) = 'identity.person.weight';

Struct Expansion

unit: UPPER(COALESCE(REGEXP_EXTRACT({col}, '([A-Z]+)$'), CASE WHEN CAST(REGEXP_EXTRACT({col}, '^([0-9.]+)') AS DOUBLE) > 100 THEN 'LBS' ELSE 'KG' END))
value: CAST(REGEXP_EXTRACT({col}, '^([0-9.]+)') AS DOUBLE)

JSON Schema

finetype schema identity.person.weight
{
  "$id": "https://noon.sh/schemas/identity.person.weight",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Person weight in kg, lbs, or other units (e.g., 75kg, 165lbs). Transforms to DOUBLE (kilograms). Decompose extracts value and unit.",
  "examples": [
    "75 kg",
    "165 lbs",
    "68.5 kg",
    "170 pounds"
  ],
  "pattern": "^[0-9]+(\\.[0-9]+)?\\s*(kg|lbs|lb|g|oz|stones)?$",
  "title": "Weight",
  "type": "string"
}

Examples

75 kg165 lbs68.5 kg170 pounds

Types in identity