-
-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catch and report duplicate column names in header line #327
Comments
I have a case that may change your mind. We get csv files from other companies to parse:
, with a schema like this: @JsonPropertyOrder({"id", "name"})
class A {
@JsonProperty("Id")
@JsonAlias({"Identification", "ID"})
public int id;
@JsonProperty("Name")
@JsonAlias({"Caption", "Title"})
public String name;
} It worked fine. Pay attention to the aliases, because there are several possible variations. And one day, their schema changed, adding another column "ID".
Although there are now two columns named "ID", we can tell the difference. @JsonPropertyOrder({"idNumber", "name", "idString"})
class A2 {
@JsonProperty("Id")
@JsonAlias({"Identification", "ID"})
public int idNumber;
@JsonProperty("Name")
@JsonAlias({"Caption", "Title"})
public String name;
@JsonProperty("IdString")
@JsonAlias({"IDString", "ID"})
public String idString;
} This will cause exceptions. "ID" will always map to "IdNumber", but the new column is not int type. Because there are two duplicated columns, now the order of the headers matters. The schema of the headers is out of our control. We can only adapt to it. As jackson csv is a library for general purposes, I don't think the order of the headers should be totally ignored. BTW, we are using |
Sorry, we met this issue because we incorrectly used |
(note: offshoot of a comment in #285)
It looks like code does not currently check that the column names included in the header line are unique; meaning that one name may be occur more than once, and in that case the last one is used.
This should not be allowed: column names in header line should not have duplicates.
The text was updated successfully, but these errors were encountered: