ofekisr commented on a change in pull request #17466:
URL: https://github.com/apache/superset/pull/17466#discussion_r752170447
##########
File path: superset/common/query_context.py
##########
@@ -92,19 +92,22 @@ def __init__(
self,
datasource: DatasourceDict,
queries: List[Dict[str, Any]],
- force: bool = False,
- custom_cache_timeout: Optional[int] = None,
result_type: Optional[ChartDataResultType] = None,
result_format: Optional[ChartDataResultFormat] = None,
+ force: bool = False,
+ custom_cache_timeout: Optional[int] = None,
) -> None:
self.datasource = ConnectorRegistry.get_datasource(
str(datasource["type"]), int(datasource["id"]), db.session
)
- self.force = force
- self.custom_cache_timeout = custom_cache_timeout
self.result_type = result_type or ChartDataResultType.FULL
self.result_format = result_format or ChartDataResultFormat.JSON
- self.queries = [QueryObject(self, **query_obj) for query_obj in
queries]
+ for qd in queries:
+ qd.setdefault("result_type", result_type)
+ query_object_factory = QueryObjectFactory()
+ self.queries = [query_object_factory.create(**query_obj) for query_obj
in queries]
Review comment:
1. In general, using class methods should be avoided, hard to test.
2. this is only a temp change, after that PR will be another PRs so the
Factory will move to another module and config will be injected to it so it
wont be couple to superset
--
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]