Skip to content

Normalize whitespace in country/state/city names - #70

Closed
victore13 wants to merge 1 commit into
mainfrom
fix/json-whitespace-normalization
Closed

Normalize whitespace in country/state/city names#70
victore13 wants to merge 1 commit into
mainfrom
fix/json-whitespace-normalization

Conversation

@victore13

Copy link
Copy Markdown
Collaborator

Qué hace

Limpia campos de nombre en los JSON que arrastraban espacios/tabs sobrantes o dobles ("The Gambia ", "Barisal ", "Trashi Yangtse\t"…) — molestos en dropdowns y rompen búsquedas/joins por texto en las apps consumidoras.

  • 874 campos normalizados (trim + colapso de whitespace a un solo espacio) en countries (name/native/capital/nationality), states (name/country_name) y cities (name/state_name/country_name).
  • Propagación a denormalizados: misma regla determinista → states.country_name, cities.state_name, cities.country_name quedan consistentes con su origen.
  • Test de integridad en streaming que falla si algún nombre vuelve a tener whitespace (blinda futuras regeneraciones del JSON).

Seguro para producción

  • No cambian ids, FKs ni nº de registros — solo el texto de los nombres. Diff mínimo y reviewable (cities: 808 líneas de 151k).
  • Auditoría integral tras el cambio: 0 errores de integridad referencial.
  • Las instalaciones existentes lo reciben en el próximo re-seed atlas:*; nada se rompe hasta entonces.

Relación con otros PRs

Fuera de alcance (a propósito, documentado aparte)

  • 3.840 ciudades con state_code en esquema distinto al de su estado (numérico vs alfabético): la FK state_id es correcta; es característica del dataset origen, no se toca.
  • 61 "estados duplicados" por nombre = mismo lugar en distinto nivel administrativo (no son duplicados reales).

Cleans up name-like fields in the shipped JSON that carried leading or
trailing spaces, stray tabs or collapsible double spaces (e.g.
"The Gambia ", "Barisal ", "Trashi Yangtse\t"). These surface as ugly
dropdown entries and break text-based lookups/joins in consuming apps.

- 874 fields normalized: trim + collapse any whitespace run to a single
  space, across countries (name/native/capital/nationality), states
  (name/country_name) and cities (name/state_name/country_name).
- Denormalized copies are normalized with the same deterministic rule,
  so states.country_name / cities.state_name / cities.country_name stay
  consistent with their source records.
- Add a streamed data-integrity test that fails if any shipped name
  field regains whitespace (guards future JSON regenerations).

Production-safe: no ids, foreign keys or record counts change — only the
text of name fields. Existing installs pick up the clean values on the
next `atlas:*` re-seed; nothing breaks until then.

Changelog: fixed
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant