A data engineer is building an Auto Loader pipeline to ingest product catalog CSV files from an S3 bucket. The CSV files include a header row, may have trailing whitespace in values, and contain a product_launch_date column that the engineer wants stored as a DATE type rather than a string for downstream compatibility. The engineer wants to enable schema inference so the schema does not need to be fully hardcoded, but wants to enforce the DATE type for product_launch_date via a schema hint. The cloudFiles.schemaLocation should be set to /checkpoints/catalog/schema, and the checkpointLocation should be /checkpoints/catalog. Which Auto Loader configuration fragment correctly satisfies all requirements?
Show answer & explanation
Correct answer: D
WHY D: Option D is the most complete and accurate. For CSV files, Auto Loader defaults to inferring all columns as strings. To get actual typed inference (integers, booleans, dates, etc.), cloudFiles.inferColumnTypes=true must be set. cloudFiles.schemaHints then allows specifying the exact type for product_launch_date as DATE — schema hints work alongside inference to enforce known column types. header=true is needed for CSV header processing, and ignoreTrailingWhiteSpace=true trims trailing whitespace. WHY NOT A: Partially correct but incomplete. Without cloudFiles.inferColumnTypes=true, all CSV columns (other than the schema-hinted product_launch_date) are inferred as strings rather than their native types (e.g., numeric columns stay as strings). WHY NOT B: inferSchema is a standard Spark CSV option, not the Auto Loader equivalent. For Auto Loader, use cloudFiles.inferColumnTypes. The schema option sets a full explicit schema, not a partial type hint. ignoreTrailingWhiteSpace=false also disables the required whitespace trimming. WHY NOT C: Using .format('json') would make Databricks attempt to read the files as JSON — the cloudFiles.format option does not override the outer .format() call. Auto Loader requires .format('cloudFiles') as the stream format.