Data sources
Choose how to collect files, database records, API responses, and event logs. Work through JDBC and HTTP examples.
Data stores, databases, warehouses and marts
Four terms describe the systems data is kept in and read from. They overlap, so learn what each one implies.
| Term | What it means | Traits to remember |
|---|---|---|
| Data store | Any repository that persistently stores and manages data. Broad term; usually implies unstructured or semi-structured data. | A database is a subset. Can be flat files, email, distributed storage, directory services. |
| Database | A data store for structured or semi-structured data that needs formal design and modeling | Relational (row or column oriented) or non-relational. "Database" usually means a relational row store such as MySQL, SQL Server, PostgreSQL, MariaDB. |
| Data warehouse | Store designed for analytics, generally column oriented, for terabytes and millions of rows | Optimized for aggregations; "hot" (fast answers) but queried for periodic reports rather than real time; fed by ETL from operational databases; essentially read-only (load, then read; not transactional). |
| Data mart | A subset of a warehouse focused on one business area or team | Smaller (a common rule of thumb is under 100 GB), read-only, cheaper and faster to query, so accessed more often. |
In a lakehouse, a "data mart" is usually a gold schema per domain (for example main.gold_finance) with its own Unity Catalog grants, rather than a separate system.
Sources and their typical ingestion
BI and ETL tools connect to many sources and extract data in one of three ways: on demand when a report runs, on a schedule, or as a continuous stream. The mechanism differs by source.
| Source | Examples | Typical Databricks ingestion |
|---|---|---|
| Files in cloud object storage | CSV, JSON, Parquet drops in S3, ADLS Gen2, GCS | Auto Loader, COPY INTO, read_files |
| Local files | A CSV on your laptop | UI "Create or modify table" upload, or upload to a volume |
| Operational databases | SQL Server, PostgreSQL, MySQL, Oracle | Lakeflow Connect managed database connectors (CDC), JDBC reads, Lakehouse Federation (query in place) |
| SaaS applications | Salesforce, Workday, ServiceNow, Google Analytics | Lakeflow Connect managed connectors, partner tools such as Fivetran |
| Message buses / event streams | Apache Kafka, Amazon Kinesis, Azure Event Hubs, Google Pub/Sub | Structured Streaming source, streaming tables |
| REST APIs | Vendor HTTP APIs | Python requests in a notebook, landing JSON to a volume or table, scheduled by Lakeflow Jobs |
| Other Databricks / partners | Data shared by another company | Delta Sharing, Marketplace |
Push vs pull
- Pull: Databricks reads from the source on a schedule (JDBC query, API call, listing files).
- Push: the source sends data (to Kafka, to a storage bucket). Databricks reacts with a stream or a file arrival trigger.
Reading a database with JDBC
df = (spark.read.format("jdbc")
.option("url", "jdbc:postgresql://host:5432/shop")
.option("dbtable", "public.orders")
.option("user", dbutils.secrets.get("shop-scope", "pg-user"))
.option("password", dbutils.secrets.get("shop-scope", "pg-pass"))
.load())
df.write.mode("append").saveAsTable("main.bronze.orders")
Never hardcode credentials. Use secrets: dbutils.secrets.get(scope, key). Secret values are redacted (shown as [REDACTED]) in notebook output. Secret scopes are created with the Databricks CLI or API.
Reading from a REST API
import requests, json
resp = requests.get("https://api.example.com/v1/rates", timeout=30)
resp.raise_for_status()
dbutils.fs.put("/Volumes/main/raw/landing/rates_2026-11-17.json", resp.text, overwrite=True)
Land the raw response to a volume, then let Auto Loader pick it up into bronze. That keeps ingestion replayable.
Audit logs as a data source
Databricks itself produces data, such as audit logs and system tables. Audit logs delivered to your storage bucket are JSON files, typically delivered within 15 minutes of the event, and a later delivery can overwrite an existing file. Pipelines reading them must tolerate overwrites. Today most teams query the system.access.audit system table instead.
Choose a source contract
A web API enforces a per-minute rate limit and supplies a cursor for its next page. When should the pipeline advance its stored cursor?
Check your reasoning
Advance only after durably landing the page or committing its records. A retry can then re-read the previous page. Keep a stable record key or page identifier so replay is safe.
Product reference
Ingest data with SQL and Spark APIs in the Databricks documentation
Data sources quiz
Answer 4 questions. Check each answer for an explanation.