I'm trying to load the flow files into MySQL database using bulk load option. Below is the query I'm using as part of the UpdateAttribute processor and passing that query to PutSQL after updating the parameters to do bulk load.
LOAD DATA INFILE '${absolute.path}${filename}' INTO TABLE ${dest.database}.${db.table.name} FIELDS TERMINATED BY ',' LINES TERMINATED BY '
'
When I ran the flow it's failing saying file not found exception.
. There were a total of 1 FlowFiles that failed, 0 that succeeded, and 0 that were not execute and will be routed to retry; : java.sql.BatchUpdateException: Unable to open file 'data.csv'for 'LOAD DATA INFILE command.Due to underlying IOException:`
** BEGIN NESTED EXCEPTION **
java.io.FileNotFoundException
MESSAGE: data.csv (No such file or directory)
java.io.FileNotFoundException: data.csv (No such file or directory).
Here MySQL Server and Nifi are on different nodes so I can't use LOAD DATA LOCAL INFILE query.
I'm not sure why I'm getting file not found exception even though I mentioned the complete absolute path of the flow file in the SQL Query.
When I use query with hard coded file name and providing the absolute path of the file in nifi node, it's working as expected.
Working:
LOAD DATA LOCAL INFILE '/path/in/nifi/node/to/file/data.csv' INTO TABLE ${dest.database}.${db.table.name} FIELDS TERMINATED BY ',' LINES TERMINATED BY '
'}
Question is how to get the absolute path of the flow file and load the same flow file into mysql.
Flow:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…