Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Databricks · Databricks Data Engineer Professional

Files, message buses, and Lakeflow Connect

Databricks Data Engineer Professional · Lesson 8 of 21 · 1:08:24

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Databricks Certified Data Engineer Professional exam. In this lesson: ingesting file formats, reading message buses (Apache Kafka, Amazon Kinesis, and Google Pub/Sub), Lakeflow Connect for databases, and keeping changes safe. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Three new sources

Quayside Eats must now bring three new sources into its lakehouse: menu photos dropped in cloud storage, courier positions streamed through Kafka, and the orders of its SQL Server database, with every insert, update, and delete. Each source needs a different tool, and choosing the wrong one means custom code to maintain, or lost changes. This lesson covers file formats, message buses, and Lakeflow Connect for databases.

File formats

Delta is the default table format on Databricks, and Unity Catalog can also expose managed tables to Apache Iceberg readers. For files, Spark reads Parquet, ORC, Avro, JSON, CSV, XML, and plain text, in batch or as a stream with Auto Loader. For images, PDFs, or any other unstructured files, the binaryFile format turns each file into one row, with its path, its modification time, its length, and its content as bytes. A path glob filter, like star dot J P G, keeps only the files you need, and the bytes can then feed a model or a parsing function. In Lakeflow pipelines, the same formats go through read_files, or through Auto Loader with the cloudFiles format option.

Message buses

For Apache Kafka, a stream reads with the kafka format, the bootstrap servers, and subscribe, or a subscribe pattern for several topics, and starting offsets decide where a new query begins. Kafka keys and values arrive as binary, so cast the value to a string and parse it with from_json, or decode Avro with from_avro, and in SQL, read_kafka does the same inside a streaming table. Amazon Kinesis uses the kinesis format, with a stream name or a stream ARN, never both, and credentials from a Unity Catalog service credential, and its payload sits in a binary data column. Google Pub/Sub uses the pubsub format, with a subscription, a topic, and a project ID. Databricks reads each message once on the subscriber side, but Pub/Sub itself can deliver the same message twice, or out of order, so remove the repeats downstream. And with the available now trigger, the same streaming code can run as an incremental batch job.

Lakeflow Connect for databases

Lakeflow Connect offers managed connectors that ingest relational databases with change data capture, into streaming tables stored as SCD type 1 or type 2. For SQL Server, standard CDC uses two parts: an ingestion gateway that runs continuously, extracts the changes, and keeps them in a staging volume, and an ingestion pipeline that loads them into the target tables. Integrated CDC uses a single pipeline that references a Unity Catalog connection, and extracts the changes at each update. MySQL uses an integrated CDC pipeline, and PostgreSQL, in preview, needs logical replication, a replication user, and publications and replication slots, set up in the source database first. New and deleted columns are handled automatically, but data type changes are not, and on SQL Server, a renamed column needs a full refresh. The connectors can be created in the UI, with the API, or with bundles.

Keeping changes safe

With standard CDC, never stop the ingestion gateway by hand. The source database keeps its change logs only for a while, so a stopped gateway can miss changes that are cleaned up in the meantime. Those tables then need a full refresh, which reloads them from the source.

Recap

Let's recap. Spark reads Parquet, ORC, Avro, JSON, CSV, XML, and text, and binaryFile turns each unstructured file into a row of bytes. Kafka values arrive as binary: cast them, then parse them with from_json or from_avro. Kinesis takes a stream name or an ARN, and Pub/Sub can deliver a message twice, so remove the repeats downstream. Lakeflow Connect ingests SQL Server, MySQL, and PostgreSQL with change data capture, into SCD type 1 or type 2 tables. And with standard CDC, the ingestion gateway runs continuously, or tables need a full refresh.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. A data science team needs a table of the menu photos in a volume, with the path, the size, and the raw bytes of each image, to feed a vision model. Which format fits?

    • text
    • binaryFile
    • parquet
    • delta
    Show the answer

    binaryFile

    The binaryFile format returns one row per file, with its path, its length, and its content as bytes. “text” would treat the photos as lines of text, and break the bytes apart. “parquet” reads Parquet files, not images. And “delta” reads Delta tables, not image files.

  2. A stream reads courier positions from Kafka, and the value column shows unreadable bytes instead of the JSON that the producer sent. What should the data engineer do?

    • Cast the value to a string, then apply from_json
    • Set the format option to json on the stream
    • Change startingOffsets to earliest
    • Decode the value with from_avro
    Show the answer

    Cast the value to a string, then apply from_json

    Kafka values arrive as binary, so cast the value to a string, then parse it with from_json and the expected schema. “Set the format option to json on the stream” would read JSON files, instead of the Kafka topic. “Change startingOffsets to earliest” would only change where the query begins. And “Decode the value with from_avro” would decode Avro, while the producer sends JSON.

  3. To save cost, an engineer stops the SQL Server ingestion gateway every weekend. After a long weekend, several tables report missing changes. What should the team do?

    • Store the target tables as SCD type 2
    • Run the ingestion pipeline more often
    • Restart the gateway earlier on Mondays
    • Keep the gateway running, then fully refresh
    Show the answer

    Keep the gateway running, then fully refresh

    The gateway must run continuously, since the source cleans up its change logs, and the affected tables need a full refresh. “Store the target tables as SCD type 2” would change how history is stored, and would not bring back the missing changes. “Run the ingestion pipeline more often” would load the staging volume more often, but the gateway still misses changes while it is stopped. And “Restart the gateway earlier on Mondays” would leave the same gap, since the gateway still stops every weekend.