OvertureMaps / OvertureMaps/schema

SourceTags should be dict[str, str], not dict[str, Any]

Open Beginner friendly
#694 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
213
Forks
22
Avg merge
3d 3h
Merged PRs (30d)
31

Description

Summary

SourceTags is typed dict[str, Any], and it should be dict[str, str].

SourceTags = NewType("SourceTags", Annotated[dict[str, Any], Field(description=...)])
# packages/overture-schema-theme-base/src/overture/schema/base/_common.py:38

The pre-Pydantic hand-written YAML had:

sourceTags:
  description: Any attributes/tags from the original source data that should be passed through.
  type: object

type: object with no additionalProperties is JSON Schema's unconstrained object, which is what dict[str, Any] renders faithfully.

Why str is right
  • Source tags are OSM tags, which are string-valued. Every source_tags example in the repo
    is string-valued: natural: dune, surface: sand, leisure: pitch, water: ocean, waterway: river.
  • There is no coercion anywhere to support a wider type — no validator on SourceTags or
    source_tags, in either the Pydantic model or the old YAML.
  • It is not an output change. PySpark already emits
    MapType(StringType(), StringType(), True) for this field, so narrowing the model makes it match what is already being produced rather than altering it.

There is also reason to think no non-string value is being written today: the PySpark schema already declares MapType(StringType(), StringType(), True), and Spark enforces the declared schema on write, so a non-string value would have failed rather than passed through. Narrowing the model records what the data already has to satisfy.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/overture-schema-theme-base/src/overture/schema/base/_common.py:38 and inspect the SourceTags definition and related Pydantic model usage. Compare it with the repository's source_tags examples and the existing PySpark MapType(StringType(), StringType(), True) schema. Done means the model type records string-valued tags without changing the emitted schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.