Meridianmeridian

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
identity
Category
person
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

Expression
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://meridian.online/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",
  "x-finetype-broad-type": "DOUBLE",
  "x-finetype-transform": "CASE\n  WHEN UPPER({col}) LIKE '%LB%' THEN CAST(REGEXP_EXTRACT({col}, '^([0-9.]+)') AS DOUBLE) / 2.20462\n  ELSE CAST(REGEXP_EXTRACT({col}, '^([0-9.]+)') AS DOUBLE)\nEND\n"
}

Examples

75 kg165 lbs68.5 kg170 pounds