[GitHub] Mogball commented on a change in pull request #3509: Add Table performance improvements
Mogball commented on a change in pull request #3509: Add Table performance improvements URL: https://github.com/apache/incubator-superset/pull/3509#discussion_r140553437 ## File path: superset/models/core.py ## @@ -743,6 +744,16 @@ def get_perm(self): return ( "[{obj.database_name}].(id:{obj.id})").format(obj=self) +def has_table(self, table): +engine = self.get_sqla_engine() +return engine.dialect.has_table( +engine, table.table_name, table.schema or None) + +def get_dialect(self): +sqla_url = url.make_url(self.sqlalchemy_uri_decrypted) +entrypoint = sqla_url._get_entrypoint() Review comment: Oh, turns out we can just call `sqla_url.get_dialect()` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] Mogball commented on a change in pull request #3509: Add Table performance improvements
Mogball commented on a change in pull request #3509: Add Table performance improvements URL: https://github.com/apache/incubator-superset/pull/3509#discussion_r140552810 ## File path: superset/models/core.py ## @@ -743,6 +744,16 @@ def get_perm(self): return ( "[{obj.database_name}].(id:{obj.id})").format(obj=self) +def has_table(self, table): +engine = self.get_sqla_engine() +return engine.dialect.has_table( +engine, table.table_name, table.schema or None) + +def get_dialect(self): +sqla_url = url.make_url(self.sqlalchemy_uri_decrypted) +entrypoint = sqla_url._get_entrypoint() Review comment: Sounds good. I was looking for a way to cache the `sqla_engine` because that function does get called frequently. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] Mogball commented on a change in pull request #3509: Add Table performance improvements
Mogball commented on a change in pull request #3509: Add Table performance improvements URL: https://github.com/apache/incubator-superset/pull/3509#discussion_r140281124 ## File path: superset/models/core.py ## @@ -743,6 +744,16 @@ def get_perm(self): return ( "[{obj.database_name}].(id:{obj.id})").format(obj=self) +def has_table(self, table): +engine = self.get_sqla_engine() +return engine.dialect.has_table( +engine, table.table_name, table.schema or None) + +def get_dialect(self): +sqla_url = url.make_url(self.sqlalchemy_uri_decrypted) +entrypoint = sqla_url._get_entrypoint() Review comment: There's a bit more overhead to it, plus creating an engine just to get the dialect and then ignoring the instance seems wasteful. These few lines are what `create_engine` does to determine dialect anyway. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services