public StructType add(String name, DataType dataType, Metadata metadata) {
        return new StructType(on(
                new ArrayList<>(fields.size() + 1),
                ArrayList::addAll, fields,
                ArrayList::add, new StructField(name, dataType, metadata)));
    }
Returns all field names in an array.
indexr-query-opt/src/main/java/org/apache/spark/sql/types/StructType.java