Skip to content

Commit 4dbdbbf

Browse files
committed
fix: ✨ Add rev key to Images in Parquet
1 parent 4c07ac0 commit 4dbdbbf

File tree

1 file changed

+4
-2
lines changed
  • openfoodfacts_exports/exports/parquet

1 file changed

+4
-2
lines changed

openfoodfacts_exports/exports/parquet/common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Image(BaseModel):
2323
sizes: dict[str, ImageSize] | None = None
2424
uploaded_t: int | None = None
2525
imgid: int | None = None
26+
rev: int | None = None
2627
uploader: str | None = None
2728

2829
@model_validator(mode="after")
@@ -242,13 +243,13 @@ def parse_language_fields(cls, data: dict) -> dict:
242243
@classmethod
243244
def parse_images(cls, data: dict) -> dict:
244245
"""Parse images field into a list of dictionaries with `key`, `imgid`,
245-
`sizes`, `uploaded_t`, and `uploader` keys.
246+
`rev`, `sizes`, `uploaded_t`, and `uploader` keys.
246247
247248
In Open Food Facts, images are stored as a dictionary with the image
248249
key as the key and the image data as the value.
249250
250251
To make the schema compatible with Parquet, we convert these fields
251-
into a list of dictionaries with `key`, `imgid`, `sizes`, `uploaded_t`,
252+
into a list of dictionaries with `key`, `imgid`, `rev`, `sizes`, `uploaded_t`,
252253
and `uploader` keys. We copy the image key (ex: `3`, `nutrition_fr`,...)
253254
from the original dictionary and add it as a field under the `key` key.
254255
"""
@@ -283,6 +284,7 @@ def parse_owner_fields(cls, data: dict):
283284
[
284285
pa.field("key", pa.string(), nullable=True),
285286
pa.field("imgid", pa.int32(), nullable=True),
287+
pa.field("rev", pa.int32(), nullable=True),
286288
pa.field(
287289
"sizes",
288290
pa.struct(

0 commit comments

Comments
 (0)