Self-describing records, choice types and Glue transforms for messy data — and when to drop down to DataFrames.
A Spark DataFrame has one fixed schema, decided before any row is processed. A Glue DynamicFrame is a collection of DynamicRecords — each record is self-describing, like a row that carries its own field names and types. Glue computes a schema on demand, when you print it or write the data.
That makes DynamicFrames forgiving with semi-structured input: JSON where fields come and go, CSV columns that are sometimes numbers and sometimes text. You create them through GlueContext, either from a Data Catalog table or straight from a connection.
orders = glueContext.create_dynamic_frame.from_catalog(
database="sales", table_name="raw_orders",
transformation_ctx="src_orders")
events = glueContext.create_dynamic_frame.from_options(
connection_type="s3",
connection_options={"paths": ["s3://raw/events/"],
"recurse": True},
format="json",
transformation_ctx="src_events")
events.printSchema() # schema computed from the records nowReach the last step for the run summary: the key takeaways from this lesson.