AWS Data Engineer DEA-C01 · Data Ingestion and Transformation · hard

During an AWS Glue PySpark job, an incoming JSON feed contains a price field that is sometimes an int (25), sometimes a double (25.50), and sometimes a string ("$25.00"). Standard Spark DataFrame schema inference either fails or coerces the entire column to string. Which AWS Glue DynamicFrame method is specifically designed to resolve inconsistent column data types across rows (by casting, projecting, or splitting into separate typed columns)?

Published · Last updated · checked before publication — how we verify questions

Options

  • Adf.dropDuplicates() on a standard Spark DataFrame
  • Bdf.coalesce(1) to merge all partitions into one file
  • CDynamicFrame.resolveChoice() with cast or make_cols specsCorrect answer
  • Dspark.catalog.clearCache() before writing to Amazon S3

Answer: C. DynamicFrame.resolveChoice() with cast or make_cols specs

An AWS Glue DynamicFrame wraps each record in a self-describing DynamicRecord that can hold multiple data types (ChoiceType) in a single field, and provides the .resolveChoice(specs=[...]) transformation (cast:double, make_cols, make_struct, or project:double) to disambiguate polymorphic schemas cleanly.

Why the other options are wrong

  • A. df.dropDuplicates() on a standard Spark DataFrame — dropDuplicates removes duplicate rows and does not resolve polymorphic schema types within a column.
  • B. df.coalesce(1) to merge all partitions into one file — coalesce(B) reduces partition count on write and has no effect on mixed column data types.
  • D. spark.catalog.clearCache() before writing to Amazon S3 — Clearing Spark's in-memory cache does not disambiguate mixed JSON field types.

All Data Ingestion and Transformation questions and the topic overview →

AWS and Amazon Web Services are trademarks of Amazon.com, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Amazon Web Services.