Two representations inside one Spark job
How Glue Spark jobs use DynamicFrames and DataFrames to join source datasets, resolve schema differences, and transform data for output. · associate
An AWS Glue Spark job reads datasets, transforms distributed records, and writes the result. Within the job, you can use Glue DynamicFrames, Spark DataFrames, or both. They are representations of data inside the job—not separate processing services.
A DynamicFrame represents self-describing records and can represent a field with more than one observed type using a choice type. This helps when incoming records disagree about a field's type. A DataFrame has a defined schema: each column has a declared type. It gives you Spark's DataFrame operations and SQL, including joins, expressions, and aggregations.
Choose the representation for the work. You might read data into DynamicFrames, resolve inconsistent types, and then call dyf.toDF() for Spark transformations. You can convert back with DynamicFrame.fromDF(df, glueContext, "result") when you need a DynamicFrame-based operation or writer. Conversion is not required merely because the job runs in Glue, and it does not replace deliberate schema cleanup.
| Representation | Schema handling | Typical use |
|---|---|---|
| DynamicFrame | Can represent choice types | Glue schema transforms |
| DataFrame | Declared column types | Spark SQL and aggregations |