surfaceextractionparse_phone
Extractionscalar · returns json

PARSE_PHONE

Parse phone number into JSON with fields: country_code, area_code, e164, national, international, is_valid, type

Per-row — runs once for each row.

extractionllmtext

Syntax

PARSE_PHONE({{ phone }})
PARSE_PHONE({{ phone }}, '{{ default_country }}')

Arguments

nametypedescription
phoneVARCHAR
default_country(optional)VARCHAR

About

Parse phone number into structured components and normalized formats. Returns JSON — use ->> operator to extract fields: PARSE_PHONE(num) ->> 'e164' -- "+15551234567" PARSE_PHONE(num) ->> 'national' -- "(555) 123-4567" PARSE_PHONE(num) ->> 'country_code' -- "1" Backend: deterministic Python via Google's `phonenumbers` library. This is the same library Google uses in Android to validate numbers and do E.164 normalization — it knows about every country's numbering plan, catches invalid numbers (too short, impossible prefixes), and handles international format detection natively. For LLM-style parsing (truly mangled input where even phonenumbers can't help), use PARSE_PHONE_LLM — see parse_phone_single_llm.cascade.yaml.

Examples

Phone extracted from text

SELECT
  parse_phone ('Call me at (555) 123-4567')

International format

SELECT
  parse_phone ('+44 20 7946 0958')

Vanity/mixed format returns a JSON object

SELECT
  parse_phone ('1-800-FLOWERS')

Nearby rabbit holes

same domain
Climb back to The Looking Glass