I'm trying to find out if there's a way to directly query a struct from a Spark schema derived from a dataset of rows. Is there some sort of Java equivalent to the Scala provided dataframe.schema("nameOfStruct")?
I've tried finding such a prebuilt function, but the only thing I could find was a way to iterate through a list of Structs or make an iterator. This seems really redundant when Scala provides a much easier way of doing things, especially if I don't want to check through a loop or find the exact index of my desired Struct.
//adding the metadata to a column
final Metadata metadata = new MetadataBuilder().putLong("metadataExample", 1).build();
final Dataset<Row> dfWithColumnMetadata = df1.withColumn("column_example", df.col("column_example"), metadata);
/*now I want to find the exact Struct and its metadata without having to loop through
an array or create an iterator. However, the array version is the easiest way I could find.
The con here is that I need to know the exact index of the column.*/
System.out.println(dfWithColumnMetadata.schema().fields()[0].metadata().toString());
Is there a way that I could get something like Scala's df.schema("column_example").metadata() ?