PU-101 commented on a change in pull request #10244:
URL:
https://github.com/apache/incubator-superset/pull/10244#discussion_r451356940
##########
File path: superset/connectors/sqla/models.py
##########
@@ -1188,12 +1188,16 @@ def fetch_metadata(self, commit: bool = True) -> None:
any_date_col = None
db_engine_spec = self.database.db_engine_spec
db_dialect = self.database.get_dialect()
- dbcols = (
- db.session.query(TableColumn)
- .filter(TableColumn.table == self)
- .filter(or_(TableColumn.column_name == col.name for col in
table_.columns))
- )
- dbcols = {dbcol.column_name: dbcol for dbcol in dbcols}
+
+ try:
+ dbcols = (
+ db.session.query(TableColumn)
+ .filter(TableColumn.table == self)
+ .filter(TableColumn.column_name.in_([col.name for col in
table.columns]))
+ )
+ dbcols = {dbcol.column_name: dbcol for dbcol in dbcols}
+ except Exception as e:
+ logger.error("Failed to get columns: " + str(e))
Review comment:
> What exception are we trying to catch here? In general we should
always try to be as specific as possible as to what exception we are expecting
to see, as opposed to catching all `Exception`.
we are trying to catch any exception , because i can't identify possible
exception when we query `table_columns` in sqlite3.
And if there is no `try...except...` block, the table seems to be added
normally except columns,but there's no any error log.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]