This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git
The following commit(s) were added to refs/heads/main by this push:
new a3d529b sql-catalog: Fix Postgres initialization when tables do not
exist (#356)
a3d529b is described below
commit a3d529b690c93483e413940f61d98e8265db4657
Author: Rahij Ramsharan <[email protected]>
AuthorDate: Sun Feb 4 21:42:50 2024 +0000
sql-catalog: Fix Postgres initialization when tables do not exist (#356)
* fix postgres catalog initialization when tables do not exist
* Format
---------
Co-authored-by: Fokko Driesprong <[email protected]>
---
pyiceberg/catalog/sql.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/pyiceberg/catalog/sql.py b/pyiceberg/catalog/sql.py
index 9436e20..62a2dac 100644
--- a/pyiceberg/catalog/sql.py
+++ b/pyiceberg/catalog/sql.py
@@ -32,7 +32,7 @@ from sqlalchemy import (
union,
update,
)
-from sqlalchemy.exc import IntegrityError, NoResultFound, OperationalError
+from sqlalchemy.exc import IntegrityError, NoResultFound, OperationalError,
ProgrammingError
from sqlalchemy.orm import (
DeclarativeBase,
Mapped,
@@ -112,7 +112,10 @@ class SqlCatalog(Catalog):
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