[AIRFLOW-2030] Fix KeyError:i in DbApiHook for insert#2972
[AIRFLOW-2030] Fix KeyError:i in DbApiHook for insert#2972untwal wants to merge 1 commit intoapache:masterfrom
i in DbApiHook for insert#2972Conversation
a318573 to
dc7591e
Compare
dc7591e to
0416e81
Compare
i in DbApiHook for insert
Codecov Report
@@ Coverage Diff @@
## master #2972 +/- ##
==========================================
+ Coverage 73.12% 73.13% +<.01%
==========================================
Files 174 174
Lines 12318 12319 +1
==========================================
+ Hits 9008 9009 +1
Misses 3310 3310
Continue to review full report at Codecov.
|
|
Can you post the error? I think the |
|
@Fokko please check this one too |
|
Hi @untwal. Changing the logline to: Would also solve the issue and make the code a bit more beautiful. Introducing this |
|
Hi @Fokko, but this variable won't be present because these rows are empty, will throw a NameError at 225 line. I can better write it as self.log.info("Done loading. Loaded a total of {0} rows".format(locals().get('i', 0)))this |
|
LOL, I was looking at the wrong line. I'm sorry. My suggestion would be: Having this mutable variable that is possibly being overwritten is not so nice. |
|
@Fokko this |
|
@Fokko |
|
Fair enough, thanks @untwal ! |
Closes apache#2972 from untwal/dbahook/fix_key_error
Closes apache#2972 from untwal/dbahook/fix_key_error

Make sure you have checked all steps below.
JIRA
Description
i, when there are zero rows in cursor to insert.Tests
Commits
My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
Passes
git diff upstream/master -u -- "*.py" | flake8 --diff