From a0fa0df0d897f8c4425c65bb334b0f5890ab95c7 Mon Sep 17 00:00:00 2001 From: hgollakota <43627229+hgollakota@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:19:18 -0500 Subject: [PATCH 1/2] Added support for lowercase FileFormat Modified the FileFormat class so that it utilizes EnumMeta value aliases. This allows both "AVRO" and "avro" to map to AVRO. --- pyiceberg/manifest.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pyiceberg/manifest.py b/pyiceberg/manifest.py index 649840fc66..d449265de0 100644 --- a/pyiceberg/manifest.py +++ b/pyiceberg/manifest.py @@ -93,9 +93,16 @@ def __repr__(self) -> str: class FileFormat(str, Enum): - AVRO = "AVRO" - PARQUET = "PARQUET" - ORC = "ORC" + AVRO = "AVRO", "avro" + PARQUET = "PARQUET", "parquet" + ORC = "ORC", "orc" + + def __new__(cls, value, *value_aliases): + obj = str.__new__(cls) + obj._value_ = value + for alias in value_aliases: + cls._value2member_map_[alias] = obj + return obj def __repr__(self) -> str: """Return the string representation of the FileFormat class.""" From 4813129a83b4a18a8023ba7d9de0188d27cd339f Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Wed, 15 Jan 2025 17:03:39 +0100 Subject: [PATCH 2/2] Make mypy happy --- pyiceberg/manifest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiceberg/manifest.py b/pyiceberg/manifest.py index d449265de0..233e5b4d10 100644 --- a/pyiceberg/manifest.py +++ b/pyiceberg/manifest.py @@ -97,7 +97,7 @@ class FileFormat(str, Enum): PARQUET = "PARQUET", "parquet" ORC = "ORC", "orc" - def __new__(cls, value, *value_aliases): + def __new__(cls, value: str, *value_aliases: List[str]) -> "FileFormat": obj = str.__new__(cls) obj._value_ = value for alias in value_aliases: