Is there a way to have <loadData> functionality without crashing when file is empty?

Thanks for the bug report, I haven’t gotten a chance to see what the cause is, but if failOnError doesn’t avoid the problem, there is probably nothing that can be done besides fixing the bug. I’ll try to get to it soon.


Nathan

I was thinking that I want liquibase to fail if there really is an error loading the data, but my particular case isn’t an error:

1. my CSV files do not have header rows
2. I have the following description that clearly indicates which columns are which (so header row is not needed)
       
           
           
           
       
3. The file exists but is empty

Expected:
   1. No error is thrown and liquibase proceeds as if the refactoring was successful.


Also, some documentation notes:

http://www.liquibase.org/manual/load_data

1. Says that either header or index is required, yet neither are in the example. Also, they don’t seem to be required. Something is wrong with the docs.
2. Doesn’t explain what logic is applied if neither header or index is specified.
3. For example, most likely there is an earlier “createTable” tag - can you infer the column types from that?

Thanks,
Jon

I want to load data into a database, but it is perfectly reasonable for certain tables to be empty. However, I cannot predict now which tables will be empty at the time the schema refactoring is run. throws an exception in 2.0.1 if the CSV file is empty. Adding failOnError=“false” has no effect - if the csv file is empty, loadData will still fail and throw an exception (I filed a bug on this).

FWIW, I believe I have reverse-engineered what has to happen to make the output of mysqldump import via loadData:
   1. You have to a header row in your input data (this is quite painful, since it is not supported by mysqldump)
   2. You have to specify the columns within loadData, and use the import types (numeric/string/etc) and not the underlying data types (slightly painful, but only have to do it once). In a perfect world, it would infer from the previous “createTable”
   3. You have to transform “” to “true” and “” to “false” in every file (can be done with sed script)
   4. You have to transform N to NULL (can be done with sed script).

Perhaps it would be cool to have a tool like mysqldump, except it dumped tables in a way that would understand, plus an accompanying metadata file that included the exact fragment to use to load the data (kind of like mysqldump creates a DB.txt and DB.sql for each table)