majiayu000 commented on code in PR #63530:
URL: https://github.com/apache/airflow/pull/63530#discussion_r2944057688
##########
providers/mysql/tests/unit/mysql/hooks/test_mysql.py:
##########
@@ -506,14 +506,8 @@ def test_bulk_load_custom(self, table):
IGNORE 1 LINES""",
)
self.cur.execute.assert_called_once_with(
- f"LOAD DATA LOCAL INFILE %s %s INTO TABLE `{table}` %s",
- (
- "/tmp/file",
- "IGNORE",
- """FIELDS TERMINATED BY ';'
- OPTIONALLY ENCLOSED BY '"'
- IGNORE 1 LINES""",
- ),
+ f"LOAD DATA LOCAL INFILE %s IGNORE INTO TABLE `{table}` FIELDS
TERMINATED BY ';'\n OPTIONALLY ENCLOSED BY '\"'\n IGNORE
1 LINES",
+ ("/tmp/file",),
Review Comment:
Fixed — removed the unnecessary wrapping parentheses to clean up the
assertion formatting.
##########
providers/mysql/src/airflow/providers/mysql/hooks/mysql.py:
##########
@@ -342,8 +342,8 @@ def bulk_load_custom(
conn = self.get_conn()
cursor = conn.cursor()
- sql_statement = f"LOAD DATA LOCAL INFILE %s %s INTO TABLE `{table}` %s"
- parameters = (tmp_file, duplicate_key_handling, extra_options)
+ sql_statement = f"LOAD DATA LOCAL INFILE %s {duplicate_key_handling}
INTO TABLE `{table}` {extra_options}"
+ parameters = (tmp_file,)
Review Comment:
Good point — agreed that validating `duplicate_key_handling` to only accept
`IGNORE` or `REPLACE` would be a solid follow-up. I'll open a separate PR for
that.
--
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]