Data Ingestion and Loading · Topic 3 of 3

Lakeflow Connect, JDBC and REST Sources

Databricks DEA: configuring Lakeflow Connect managed connectors, JDBC and REST ingestion from notebooks with Lakeflow Jobs, and loading nested JSON data.

  • 5 min
In a nutshell
  • A managed connector uses a Unity Catalog connection, an ingestion pipeline and streaming tables; database sources add an ingestion gateway.
  • The ingestion pipeline runs on a schedule; the first run is a full load, later runs load changes.
  • JDBC reads use spark.read.format("jdbc") with credentials from dbutils.secrets.get.

What it is

Enterprise data lives in databases, SaaS applications and APIs, not only in files. Lakeflow Connect managed connectors ingest from supported sources with no ingestion code. For anything else, a notebook uses JDBC or a REST client and a Lakeflow Job runs it on a schedule.

Much of this data is semi structured, such as JSON with nested objects and arrays. The exam expects you to land it in Delta tables and read its nested fields.

Enterprise sourceManaged connectorno codeStreaming tablesUnity CatalogOther sourceNotebookJDBC or RESTVolume or Delta tableLakeflow Jobschedule

How it works

Configuring a managed connector

Setting up a managed connector creates a few objects, all governed by Unity Catalog.

ObjectRole
ConnectionA Unity Catalog securable that stores the source credentials
Ingestion gatewayFor database sources only; runs continuously, stages changes in a volume and can need classic compute
Ingestion pipelineReads from the source or the staged changes and writes the destination tables
Streaming tablesThe destination tables in the catalog and schema you choose

You pick the source objects (tables or SaaS objects), the destination catalog and schema, and a schedule. The schedule runs the ingestion pipeline, which can also be a task in a Lakeflow Job. The database gateway runs continuously, apart from that schedule.

ConnectioncredentialsIngestion gatewaydatabases onlyIngestion pipelineStreaming tablesScheduled job

The first run loads all selected data; later runs load only changes where the source supports it. This is what makes the connector reliable: Databricks maintains the API logic, retries and schema evolution, not your team.

JDBC from a notebook

When no managed connector fits, read the database with the Spark JDBC source. Keep credentials in a secret scope, never in the notebook.

df = (spark.read.format("jdbc")
  .option("url", "jdbc:postgresql://dbhost:5432/sales")
  .option("dbtable", "public.orders")
  .option("user", dbutils.secrets.get("sales_db", "user"))
  .option("password", dbutils.secrets.get("sales_db", "password"))
  .load())
df.write.mode("append").saveAsTable("main.bronze.orders")

For large tables, partitionColumn, lowerBound, upperBound and numPartitions split the read across parallel connections. ODBC follows the same idea from tools outside Spark.

REST APIs from a notebook

A REST client such as Python requests calls the API and either lands raw responses as files or writes rows directly to a table.

import requests
resp = requests.get(api_url, timeout=30)
resp.raise_for_status()
dbutils.fs.put(f"/Volumes/main/raw/landing/api/{run_id}.json", resp.text)

Landing raw JSON in a volume first lets Auto Loader load it incrementally and keeps the original response for replay. Writing straight to a table is simpler for small responses.

Orchestrating with Lakeflow Jobs

A custom notebook is not incremental on its own. Schedule it as a notebook task in a Lakeflow Job, add retries, and track a watermark, such as the last modified timestamp, so each run reads only new rows.

ApproachMaintenanceIncrementalBest when
Managed connectorLowestBuilt in where the source supports itSource is supported
JDBC notebook plus jobHigherYou track a watermarkUnsupported database
REST notebook plus jobHigherYou track a cursor or dateCustom or internal API

Semi structured and unstructured data

JSON objects become struct columns and JSON arrays become array columns. Read nested fields with dot notation and turn arrays into rows with explode.

SELECT o.order_id, o.customer.address.city, item.sku
FROM main.bronze.orders o
LATERAL VIEW explode(o.items) AS item;

When JSON is stored as a string column, the colon syntax reads into it, as in raw:customer.id. Managed file connectors, such as SharePoint and Google Drive, and Auto Loader with the binaryFile format bring in unstructured files such as PDFs.

How the exam asks about this

  • "Ingest SQL Server tables with change data capture into Unity Catalog with minimal code." A managed connector with an ingestion gateway.
  • "An internal API has no connector; load it daily." A notebook with a REST client scheduled by a Lakeflow Job.
  • "Each order row holds an array of items; produce one row per item." Use explode on the array column.

What to remember for the exam

  • A managed connector uses a Unity Catalog connection, an ingestion pipeline and streaming tables; database sources add an ingestion gateway.
  • The ingestion pipeline runs on a schedule; the first run is a full load, later runs load changes.
  • JDBC reads use spark.read.format("jdbc") with credentials from dbutils.secrets.get.
  • Custom notebooks are scheduled as Lakeflow Job tasks and must track their own watermark.
  • Nested JSON lands as struct and array columns; use dot notation and explode.
Watch out

Hard coding a password in a JDBC option is always wrong on the exam. Credentials belong in a secret scope or, for managed connectors, in a Unity Catalog connection.

Common mistakes

Building a JDBC notebook for a supported source. If a managed connector exists, it handles CDC, retries and schema changes, so it beats custom code.

Assuming a custom JDBC read is incremental. A plain JDBC read loads the whole table every run. Incremental behavior needs a filter on a watermark column.

Flattening JSON by string parsing. Nested JSON already has structure; dot notation and explode read it without regular expressions.

Check yourself

  • Which object stores source credentials for a Lakeflow Connect managed connector?

    A Unity Catalog connection, which is a securable object, so access to it is governed like any other Unity Catalog object.

  • How does a notebook that calls a REST API run every day?

    As a notebook task in a Lakeflow Job with a schedule, ideally with retries and a stored cursor so each run fetches only new data.

  • How do you produce one row per element of an array column?

    Apply explode to the array column, for example with LATERAL VIEW explode(items) in SQL.

Topic 3 of 3 in Data Ingestion and Loading

Test yourself on Data Ingestion and Loading

The full Databricks Data Engineer Associate question bank has 598 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Databricks. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.