combax opened a new pull request, #76883:
URL: https://github.com/apache/airflow/pull/76883

   `DbApiHook.insert_rows(..., commit_every=0)` inserts nothing on the 
`executemany` path and raises no error; the log ends with "Loaded a total of 0 
rows". `commit_every=0` is documented as "insert all rows in one transaction", 
and the row-by-row path honours it, but the `executemany` path passes the value 
to `more_itertools.chunked`, which yields no chunks for a size of 0. Hooks that 
set `supports_executemany` take that path by default, `PostgresHook` among them.
   
   The hook now passes `commit_every or None`, as `AdbcHook.insert_rows` 
already does, so all rows go into one `executemany` call and one commit.
   
   Checked against a SQLite file with `executemany=True` and three rows:
   
   | `commit_every` | rows written on main | rows written with the fix |
   |---|---|---|
   | 0 | 0 | 3 |
   | 1, 2, 1000 | 3 | 3 |
   
   The new test fails on main and passes with the fix; the other `common.sql` 
hook tests pass.
   
   Not in this PR: `PostgresHook.insert_rows` has the same loop in its psycopg2 
`fast_executemany` path. That one also passes the value to 
`execute_values(page_size=...)`, so it needs its own fix and test in the 
Postgres provider.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Fable 5.2) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


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