guan404ming commented on code in PR #50143:
URL: https://github.com/apache/airflow/pull/50143#discussion_r2072530750
##########
providers/slack/src/airflow/providers/slack/transfers/base_sql_to_slack.py:
##########
@@ -70,15 +70,13 @@ def _get_hook(self) -> DbApiHook:
self.log.debug("Get connection for %s", self.sql_conn_id)
conn = BaseHook.get_connection(self.sql_conn_id)
hook = conn.get_hook(hook_params=self.sql_hook_params)
- if not callable(getattr(hook, "get_pandas_df", None)):
- raise AirflowException(
- "This hook is not supported. The hook class must have
get_pandas_df method."
- )
+ if not callable(getattr(hook, "get_df", None)):
+ raise AirflowException("This hook is not supported. The hook class
must have get_df method.")
return hook
def _get_query_results(self) -> pd.DataFrame:
sql_hook = self._get_hook()
self.log.info("Running SQL query: %s", self.sql)
- df = sql_hook.get_pandas_df(self.sql, parameters=self.parameters)
- return df
+ df = sql_hook.get_df(self.sql, parameters=self.parameters) # type:
ignore[attr-defined] # TODO: Remove this once common-sql>1.26.0 is released
+ return df # type: ignore[return-value] # TODO: Remove this once
common-sql>1.26.0 is released
Review Comment:
Since I refined the type definition for `get_df` for `common-sql` in this PR
https://github.com/apache/airflow/pull/50126 which is not included in
`common-sql=1.26.0`.
Thus it would have type issue like here before the type definition.
If my thought have any wrong, please let me know. I could modify it, thanks!
##########
providers/slack/src/airflow/providers/slack/transfers/base_sql_to_slack.py:
##########
@@ -70,15 +70,13 @@ def _get_hook(self) -> DbApiHook:
self.log.debug("Get connection for %s", self.sql_conn_id)
conn = BaseHook.get_connection(self.sql_conn_id)
hook = conn.get_hook(hook_params=self.sql_hook_params)
- if not callable(getattr(hook, "get_pandas_df", None)):
- raise AirflowException(
- "This hook is not supported. The hook class must have
get_pandas_df method."
- )
+ if not callable(getattr(hook, "get_df", None)):
+ raise AirflowException("This hook is not supported. The hook class
must have get_df method.")
return hook
def _get_query_results(self) -> pd.DataFrame:
sql_hook = self._get_hook()
self.log.info("Running SQL query: %s", self.sql)
- df = sql_hook.get_pandas_df(self.sql, parameters=self.parameters)
- return df
+ df = sql_hook.get_df(self.sql, parameters=self.parameters) # type:
ignore[attr-defined] # TODO: Remove this once common-sql>1.26.0 is released
+ return df # type: ignore[return-value] # TODO: Remove this once
common-sql>1.26.0 is released
Review Comment:
Since I refined the type definition for `get_df` for `common-sql` in this PR
https://github.com/apache/airflow/pull/50126 which is not included in
`common-sql=1.26.0`. Thus it would have type issue like here before the type
definition.
If my thought have any wrong, please let me know. I could modify it, thanks!
--
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]