loadUpdateData in liquibase, select only some columns from csv

2.3k views Asked by At

Assume having the following csv:

a,b,c
1,2,3

where a,b,c are column names and 1,2,3 are values. Is it possible to load only columns a,b?

<loadUpdateData tableName="TABLE" 
            file="file.csv"
            primaryKey="a">     
            <column name="a" header="a"/>
            <column name="b" header="b"/>
</loadUpdateData>

This will generate an SQL error, because it will try to insert column c. I am using MySQL.

1

There are 1 answers

2
Jens On BEST ANSWER

Haven't tried it myself but looking at the code (for LoadDataChange) there seems to be an option to "skip" a column config:

if ("skip".equalsIgnoreCase(columnConfig.getType())) {
    continue;
}

So maybe you can add a column config for 'c' and set its type to "skip":

<column name="c" header="c" type="skip" />