Search code examples
scalaapache-sparkrddapache-spark-sql

Schema from SchemaRDD?


Given a SchemaRDD (loaded using SQLContext.parquetFile), how do I extract its metadata/schema/list of columns?


Solution

  • The field list is accessible through the SchemaRDD as [rdd].schema.fields.

    lazy val schema: StructType
             Returns the schema of this SchemaRDD (represented by a StructType).