Skip to content

Commit

Permalink
Enum value get consistently sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Sep 4, 2023
1 parent 23605c6 commit a3b8e93
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/data_common/dataset/table_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pandas as pd
from pandas.io.json import build_table_schema

from data_common.db import duck_query


Expand Down Expand Up @@ -80,6 +81,9 @@ def enhance_field(
field["constraints"]["enum"] = enum_value
if isinstance(enum_value, EnumPlaceholder):
field["constraints"]["enum"] = enum_value.process(col)
if isinstance(field["constraints"]["enum"], list):
# sort the enum values
field["constraints"]["enum"] = sorted(field["constraints"]["enum"])
return field

@classmethod
Expand All @@ -105,7 +109,6 @@ def get_table_schema(
def update_table_schema(
path: Path, existing_schema: SchemaValidator | None
) -> SchemaValidator:

if path.suffix == ".csv":
df = pd.read_csv(path)
elif path.suffix == ".parquet":
Expand Down

0 comments on commit a3b8e93

Please sign in to comment.