ebyhr commented on code in PR #3525:
URL: https://github.com/apache/iceberg-python/pull/3525#discussion_r3441152988
##########
pyiceberg/catalog/sql.py:
##########
@@ -147,6 +153,17 @@ def _ensure_tables_exist(self) -> None:
self.create_tables()
return
+ # Idempotently add iceberg_type column if it does not exist yet
+ # (backward-compatible migration for databases created before this
column was introduced).
+ # Older SQLite versions do not support "ADD COLUMN IF NOT EXISTS", so
we catch and ignore
+ # the error if the column is already present.
+ with Session(self.engine) as session:
+ try:
+ session.execute(text("ALTER TABLE iceberg_tables ADD COLUMN
iceberg_type VARCHAR(255)"))
Review Comment:
I don't think we should add a new column in `_ensure_tables_exist` method.
It is counterintuitive. The initialization logic in #3263 looks better than
this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]