chuxiangfeng opened a new issue, #31504:
URL: https://github.com/apache/airflow/issues/31504

   ### Apache Airflow version
   
   Other Airflow 2 version (please specify below)
   
   ### What happened
   
   pass an List[sqlstr] to DbApiHook run, it can not return last correct.
   
   ### What you think should happen instead
   
   return last sql fetch result.
   the source code in DbApiHook on line 353 is
   `
                   for sql_statement in sql_list:
                       self._run_command(cur, sql_statement, parameters)
   
                       if handler is not None:
                           result = handler(cur)
                           if return_single_query_results(sql, return_last, 
split_statements):  //353 line
                               _last_result = result
                               _last_description = cur.description
                           else:
                               results.append(result)
                               self.descriptions.append(cur.description)
   `
   i overwrite get_records in sub class with this, change sql to sql_statement, 
 it make effect.
   `
                   for sql_statement in sql_list:
                       self._run_command(cur, sql_statement, parameters)
   
                       if handler is not None:
                           result = handler(cur)
                           if return_single_query_results(sql_statement, 
return_last, split_statements):  //353 line
                               _last_result = result
                               _last_description = cur.description
                           else:
                               results.append(result)
                               self.descriptions.append(cur.description)
   `
   
   ### How to reproduce
   
   call get_records in DbApiHook.
   
   ### Operating System
   
   PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" 
VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian 
HOME_URL="https://www.debian.org/"; SUPPORT_URL="https://www.debian.org/support"; 
BUG_REPORT_URL="https://bugs.debian.org/";
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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]

Reply via email to