CertLumen

Databricks Data Engineer Associate · Section 2 · 21% of the exam

Use the COPY INTO command to incrementally load files from cloud object storage (ADLS/S3/GCS) into Unity-Catalog–governed tables.

One of the objectives of the Databricks Certified Data Engineer Associate exam, in the section “Data Ingestion and Loading”. Here is what it covers, the points to remember and a question to try.

What it covers

COPY INTO is a retryable, idempotent SQL command that loads only new files from a volume or cloud path into a Delta table. Learn its clauses, schema options, in-flight transformations, the Unity Catalog access model and when Auto Loader is the better choice.

Points to remember

  • COPY INTO loads files from a volume or cloud path into an existing Delta table; it is retryable and idempotent.
  • Already-loaded files are skipped on later runs, even if modified; COPY_OPTIONS ('force'='true') disables this and can create duplicates.
  • FILES (explicit list, max 1,000) and PATTERN (glob) select files; they cannot be combined.
  • FORMAT_OPTIONS holds reader options (header, inferSchema, multiLine, mergeSchema); COPY_OPTIONS holds force and mergeSchema.
  • Schemaless placeholder: CREATE TABLE t; then COPY INTO with COPY_OPTIONS ('mergeSchema'='true') (DBR 11.3 LTS+); the documented pattern also sets it in FORMAT_OPTIONS.

Try a question

A SQL-focused team loads a few hundred CSV files per day from a volume. The bronze table must store amount as DECIMAL(10,2), parse order_ts into a TIMESTAMP, and record the source file path and load time for every row. Each run must process only newly arrived files, and reruns must not duplicate data. Which statement meets all requirements?

  1. AINSERT INTO prod.bronze.orders SELECT order_id, CAST(amount AS DECIMAL(10,2)) AS amount, to_timestamp(order_ts) AS order_ts, _metadata.file_path AS source_file, current_timestamp() AS ingested_at FROM read_files('/Volumes/prod/landing/raw/orders/', format => 'csv', header => true)
  2. BCOPY INTO prod.bronze.orders FROM (SELECT order_id, CAST(amount AS DECIMAL(10,2)) AS amount, to_timestamp(order_ts) AS order_ts, _metadata.file_path AS source_file, current_timestamp() AS ingested_at FROM '/Volumes/prod/landing/raw/orders/') FILEFORMAT = CSV FORMAT_OPTIONS ('header' = 'true') COPY_OPTIONS ('force' = 'true')
  3. CCREATE OR REPLACE TABLE prod.bronze.orders AS SELECT order_id, CAST(amount AS DECIMAL(10,2)) AS amount, to_timestamp(order_ts) AS order_ts, _metadata.file_path AS source_file, current_timestamp() AS ingested_at FROM read_files('/Volumes/prod/landing/raw/orders/', format => 'csv', header => true)
  4. DCOPY INTO prod.bronze.orders FROM (SELECT order_id, CAST(amount AS DECIMAL(10,2)) AS amount, to_timestamp(order_ts) AS order_ts, _metadata.file_path AS source_file, current_timestamp() AS ingested_at FROM '/Volumes/prod/landing/raw/orders/') FILEFORMAT = CSV FORMAT_OPTIONS ('header' = 'true')
Show the answer

D. All four options apply the same casts and audit columns, so the deciding factor is how files are tracked. COPY INTO accepts a SELECT over the source path, so you can cast columns, parse timestamps and add _metadata.file_path and current_timestamp() while keeping its idempotent, skip-already-loaded behavior. Setting force would switch that behavior off.

Written for practice in the style of the exam: never a question from the real exam.

In the course

The lesson COPY INTO teaches this objective (about 35 minutes), and 9 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.

More in this section

← Previous objective · All 29 objectives · Next objective →