Skip to content

Commit

Permalink
feat: ✨ add mapping from Frictionless data types to Polars data types (
Browse files Browse the repository at this point in the history
…#1106)

## Description

This PR adds the mapping from Frictionless data types to Polars data
types described in
#1098.

I'm adding this now because I'm using it in the checks and presumably
Signe will use it when writing to Parquet.

<!-- Select quick/in-depth as necessary -->
This PR needs a quick review.

## Checklist

- [x] Added or updated tests
- [x] Updated documentation
- [x] Ran `just run-all`
  • Loading branch information
martonvago authored Mar 6, 2025
1 parent 9aed3b2 commit eca3dbd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/seedcase_sprout/core/map_data_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import polars as pl

from seedcase_sprout.core.properties import FieldType

# Mapping from Frictionless data types to Polars data types.
# See https://sprout.seedcase-project.org/docs/design/interface/data-types
# for more information.
FRICTIONLESS_TO_POLARS: dict[FieldType, pl.DataType] = {
"string": pl.String,
"boolean": pl.Boolean,
"integer": pl.Int64,
"number": pl.Float64,
"year": pl.Int32,
"datetime": pl.Datetime,
"date": pl.Date,
"time": pl.Time,
"yearmonth": pl.Date,
"geopoint": pl.Array(pl.Float64, 2),
"duration": pl.String,
"object": pl.String,
"array": pl.String,
"geojson": pl.String,
"any": pl.String,
}

0 comments on commit eca3dbd

Please sign in to comment.