When to use this
CRMs like Pipedrive, HubSpot, and Salesforce allow users to define custom fields on entities like deals, contacts, or companies. In the raw data, these typically appear as a separate key-value table (e.g.,deal_fields) where each row maps a field key to a label, rather than as columns on the main entity table.
To make this data usable for analysis, you need to join the custom fields definition table with the main entity and pivot the key-value pairs into proper columns.
Sample input
Two tables in the Raw layer:deals — the main entity table, with custom fields stored as a JSON object mapping field keys to values:
deal_fields — the field definitions table, mapping each key to a human-readable label:
We want a final table where each custom field becomes a properly named column.
Implementation
- Nekt Express / BigQuery
- Athena SQL
- Python (Nekt SDK)
Use
JSON_VALUE to extract each custom field, with column aliases derived from the field definitions.Expected output
Tips and gotchas
In the SQL examples, the field-to-column mapping is hardcoded. If your CRM has dozens of custom fields that change frequently, the Python approach is more maintainable — it reads the definitions table and builds columns dynamically. For SQL-based pipelines, consider generating the SQL as a pre-step using a script or Nekt’s AI assistant.
Some CRMs store custom fields differently — Salesforce uses actual columns on the object, while Pipedrive and HubSpot use key-value mappings. Check how your specific source stores custom fields in the Raw layer before applying this pattern.