Skip to content

[Feature]: Join Field: match a text key with a number key, so Census tables join to TIGER tracts #1178

Closed

Description

@Mavrick-F

Before you start

  • I searched the existing issues and the roadmap and did not find a duplicate request.

What problem does this solve?

The most common US Census join fails. The Census Bureau's tract table (its Gazetteer file, or any table downloaded from data.census.gov) has an 11-digit GEOID such as 47157000100. The CSV reader types that column as a number. The TIGER/Line tract shapefile stores the same GEOID as text. Join Field then refuses:

key field type mismatch: target field 'GEOID' is Text, but source field 'GEOID' is Long

The same happens with any ID that is all digits in one file and text in the other: county and state FIPS codes, ZIP codes, parcel numbers, school or hospital ids.

Found by the nightly real-data workflow test (#1165), which joins Shelby County's 249 tracts to the Gazetteer. To make the join work, the test does what a user has to: it adds a number field to the tracts with Add Field and copies GEOID into it with Calculate Field. That's two extra steps for every join of this kind, and the message doesn't suggest them.

The message also calls the field type Long, while RustGIS's field type is named Integer (FieldType::Integer).

Proposed solution

The choice of approach is the maintainers'. These are the options I can see:

  1. Compare across types as text. When one key is text and the other a whole number, Join Field compares the number written out in full (47157000100) with the text. Leading zeros stay meaningful: the CSV reader already keeps 01001 as text, so a text 01001 would still not match the number 1001. This fixes the common case with no new parameter.
  2. A parameter for it, such as "compare": "Exact" | "As text", defaulting to Exact, with the error message pointing to it. This is more explicit, but a user still has to discover it.
  3. Keep the refusal, and improve the message: name the fix (convert one key with Add Field and Calculate Field), and use the same type names the UI uses.

Option 1 plus the clearer message from option 3 looks like the smallest change that makes the everyday case work. Either way, the nightly test in #1165 can then drop its workaround, so it doubles as the regression test.

Alternatives considered

  • Have the CSV reader keep long all-digit columns as text (say 10 digits or more, or columns whose names end in ID, GEOID or FIPS). This is a heuristic, it changes how existing tables read, and it doesn't help when the number column comes from a GeoPackage or Parquet file.
  • A way to choose a column's type when adding a CSV. This is useful on its own, but a user has to know to use it before the join fails.

Estimated scope

Small for option 1 or 3 (crates/analysis/src/attribute_join.rs, plus a test). Option 2 adds a tool parameter.

Activity

  1. added a commit that references this issue on Nov 1, 2026
    8ea05f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions