Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-3767] Correct bulk insert function #4773

Merged

Conversation

zhongjiajie
Copy link
Member

Fix Oracle hook bulk_insert bug when
target_fields is None or rows is
empty iterable

Make sure you have checked all steps below.

Jira

Description

  • Here are some details about my PR, including screenshots of any UI changes:

Fix Oracle_hook bulk_insert_rows while param target_fields is None and rows is empty iterable.

Tests

  • My PR adds the following unit tests :

test/hooks/test_oracle_hook.py function test_bulk_insert_rows_without_fields and test_bulk_insert_rows_no_rows

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":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • not a new functionality

Code Quality

  • Passes flake8

@zhongjiajie zhongjiajie force-pushed the fix_oracle_hook_bulk_insert_field_error branch 2 times, most recently from 8b50dc7 to ed239f5 Compare February 25, 2019 14:32
@codecov-io
Copy link

codecov-io commented Feb 25, 2019

Codecov Report

Merging #4773 into master will increase coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #4773     +/-   ##
=========================================
+ Coverage   74.33%   74.44%   +0.1%     
=========================================
  Files         450      450             
  Lines       28970    28972      +2     
=========================================
+ Hits        21536    21569     +33     
+ Misses       7434     7403     -31
Impacted Files Coverage Δ
airflow/hooks/oracle_hook.py 95.79% <100%> (+0.07%) ⬆️
airflow/jobs.py 76.46% <0%> (+0.71%) ⬆️
airflow/utils/dag_processing.py 59.15% <0%> (+1.05%) ⬆️
airflow/executors/__init__.py 63.46% <0%> (+3.84%) ⬆️
airflow/utils/sqlalchemy.py 81.81% <0%> (+4.54%) ⬆️
airflow/executors/sequential_executor.py 100% <0%> (+50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04e6301...0a3f460. Read the comment docs.

@zhongjiajie
Copy link
Member Author

@ashb @Fokko PTAL, Thanks.

values = ', '.join(':%s' % i for i in range(1, len(target_fields) + 1))
prepared_stm = 'insert into {tablename} ({columns}) values ({values})'.format(
if target_fields:
columns = ', '.join(target_fields)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this directly inside of the format? or give it a different name, I don't like overwriting variables :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fokko Change the code as you said, waiting for CI pass, PTAL.

Fix Oracle hook bulk_insert bug when
param target_fields is None or rows
is empty iterable
@zhongjiajie zhongjiajie force-pushed the fix_oracle_hook_bulk_insert_field_error branch 3 times, most recently from efc1141 to 125b411 Compare February 28, 2019 06:37
@zhongjiajie
Copy link
Member Author

CI test failed many many many time for no detaile resone 😭 😭 😭

@zhongjiajie zhongjiajie force-pushed the fix_oracle_hook_bulk_insert_field_error branch from 125b411 to 0a3f460 Compare March 1, 2019 00:57
@zhongjiajie
Copy link
Member Author

CI pass finally

@Fokko
Copy link
Contributor

Fokko commented Mar 4, 2019

The CI is currently super flaky 😭

Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @zhongjiajie

@Fokko Fokko merged commit d665ac1 into apache:master Mar 4, 2019
@zhongjiajie zhongjiajie deleted the fix_oracle_hook_bulk_insert_field_error branch March 5, 2019 00:59
@zhongjiajie
Copy link
Member Author

Thanks @Fokko

ashb pushed a commit that referenced this pull request Mar 19, 2019
* [AIRFLOW-3767] Correct bulk insert function

Fix Oracle hook bulk_insert bug when
param target_fields is None or rows
is empty iterable

* change without overwriting variables as Fokko said
andriisoldatenko pushed a commit to andriisoldatenko/airflow that referenced this pull request Jul 26, 2019
* [AIRFLOW-3767] Correct bulk insert function

Fix Oracle hook bulk_insert bug when
param target_fields is None or rows
is empty iterable

* change without overwriting variables as Fokko said
wmorris75 pushed a commit to modmed/incubator-airflow that referenced this pull request Jul 29, 2019
* [AIRFLOW-3767] Correct bulk insert function

Fix Oracle hook bulk_insert bug when
param target_fields is None or rows
is empty iterable

* change without overwriting variables as Fokko said
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants