Fokko commented on a change in pull request #4773: [AIRFLOW-3767] Correct bulk
insert function
URL: https://github.com/apache/airflow/pull/4773#discussion_r260763896
##########
File path: airflow/hooks/oracle_hook.py
##########
@@ -199,12 +199,20 @@ def bulk_insert_rows(self, table, rows,
target_fields=None, commit_every=5000):
Default 5000. Set greater than 0. Set 1 to insert each row in each
transaction
:type commit_every: int
"""
+ if not rows:
+ raise ValueError("parameter rows could not be None or empty
iterable")
conn = self.get_conn()
cursor = conn.cursor()
- 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)
Review comment:
Maybe move this directly inside of the format? or give it a different name,
I don't like overwriting variables :-)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services