Skip to content

Commit

Permalink
sql-catalog: Fix Postgres initialization when tables do not exist (#356)
Browse files Browse the repository at this point in the history
* fix postgres catalog initialization when tables do not exist

* Format

---------

Co-authored-by: Fokko Driesprong <[email protected]>
  • Loading branch information
rahij and Fokko authored Feb 4, 2024
1 parent a276112 commit a3d529b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pyiceberg/catalog/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
union,
update,
)
from sqlalchemy.exc import IntegrityError, NoResultFound, OperationalError
from sqlalchemy.exc import IntegrityError, NoResultFound, OperationalError, ProgrammingError
from sqlalchemy.orm import (
DeclarativeBase,
Mapped,
Expand Down Expand Up @@ -112,7 +112,10 @@ def _ensure_tables_exist(self) -> None:
stmt = select(1).select_from(table)
try:
session.scalar(stmt)
except OperationalError:
except (
OperationalError,
ProgrammingError,
): # sqlalchemy returns OperationalError in case of sqlite and ProgrammingError with postgres.
self.create_tables()
return

Expand Down

0 comments on commit a3d529b

Please sign in to comment.