score:0

Interesting idea. The way I would do it:

  1. Ingest your data in a dataframe.
  2. Write a utility method that takes the dataframe and class name (here SampleRecord).
  3. Use introspection to read the annotations (you could eventually add some if you need to define specific properties).
  4. Rename the columns with withColumnRenamed() on the dataframe.
  5. Return the modified dataframe.

hih

score:1


public class SampleRecord implements Serializable {
         private Long sampleId;

         private String name;

         private String description; 


@JsonProperty("sample_id")
public void setSampleId(Long sampleId) {
        this.sampleId = sampleId;
    }

@JsonProperty("sample_name")
public void setName(String name) {
        this.name = name;
    }


@JsonProperty("sample_desc")
public void setDescription(String description) {
        this.description = description;
    }
}

Related Query

More Query from same tag