8000 fix loading `in-memory` catalog by kevinjqliu · Pull Request #1725 · apache/iceberg-python · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@kevinjqliu
Copy link
Contributor
@kevinjqliu kevinjqliu commented Feb 25, 2025

Previously CatalogType was fetched by key, CatalogType[provided_catalog_type.upper()] (note the bracket)
This PR changes CatalogType to be fetched by value, CatalogType(provided_catalog_type.lower()) (note the parenthesis)

https://stackoverflow.com/questions/29799235/python-enum-value2member-map-accessor

This fix loading in-memory catalog, load_catalog("catalog", **{"type": "in-memory"}).
Previously, "in-memory" caused a key error because its key is IN_MEMORY. Note the - vs _.

class CatalogType(Enum):
REST = "rest"
HIVE = "hive"
GLUE = "glue"
DYNAMODB = "dynamodb"
SQL = "sql"
IN_MEMORY = "in-memory"

We want in-memory and not in_memory to match spark

spark.sql.catalogImplementation in-memory

@kevinjqliu kevinjqliu changed the title fix in-memory fix loading in-memory catalog Feb 25, 2025
@kevinjqliu kevinjqliu requested a review from Fokko February 25, 2025 23:14
Copy link
Collaborator
@sungwy sungwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting issue :)

Thanks for the fix @kevinjqliu !

@kevinjqliu kevinjqliu merged commit 8bfb16c into apache:main Feb 26, 2025
7 checks passed
@kevinjqliu kevinjqliu deleted the kevinjqliu/in-memory branch February 26, 2025 02:09
gabeiglio pushed a commit to Netflix/iceberg-python that referenced this pull request Aug 13, 2025
Previously `CatalogType` was fetched by key,
`CatalogType[provided_catalog_type.upper()]` (note the bracket)
This PR changes `CatalogType` to be fetched by value,
`CatalogType(provided_catalog_type.lower())` (note the parenthesis)


https://stackoverflow.com/questions/29799235/python-enum-value2member-map-accessor

This fix loading `in-memory` catalog, `load_catalog("catalog",
**{"type": "in-memory"})`.
Previously, `"in-memory"` caused a key error because its key is
`IN_MEMORY`. Note the `-` vs `_`.


https://github.com/apache/iceberg-python/blob/1d24e71041e35e26e126aa4508ed7384e8aa031c/pyiceberg/catalog/__init__.py#L113-L119


We want `in-memory` and not `in_memory` to match spark

https://github.com/apache/iceberg-python/blob/1d24e71041e35e26e126aa4508ed7384e8aa031c/dev/spark-defaults.conf#L35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0