Your free workspace

Part of the free LogicWiz Data Engineering course, Module 13: The lakehouse on Databricks. The SQL and Python run in the app, on real Postgres and real Python in the browser.

It is 4:40 on Friday. Your Module 11 notebook counts SwiftKart's 80 orders by status in under a second. Nora reads the five numbers and asks: "That ran on DuckDB pretending to be Spark. Do you get the same five numbers on a real cluster?" You do not have a cluster. Twenty minutes from now you will, and it costs nothing.

You'll learn to

  • Open a free Databricks workspace and know its limits
  • Say where your notebook, Spark and your data each live
  • Explain why a typo fails late on serverless
  • Move Module 11 code to real Spark and match the counts

Learn

Nora wants the same five numbers

Databricks is a company that runs Apache Spark for you, on AWS, Azure or Google Cloud. You get a web page with notebooks. It brings the machines.

Its Free Edition is the same product with small limits. You sign up with an email address. No credit card is asked for, and there is no bill.

The plan for the next twenty minutes: open a workspace, upload orders.csv, paste the Module 11 code, and compare five numbers. Two things will go wrong on the way. Each one shows you how the platform is built.

Sign up, step by step

StepDo thisYou should see
1Search the web for Databricks Free Edition and open its sign-up page on databricks.comSign up with an email address (a one-time code), or a Google or Microsoft account
2Use a personal email. No credit card is asked forDatabricks asks you to confirm your email
3Wait a minute while your workspace is createdThe workspace home page, with a sidebar on the left
4Open Catalog in the sidebarA catalog called workspace with a schema called default, and a read-only samples catalog
5Click New, then NotebookAn empty notebook, connected to serverless compute
6Type spark.range(3).show() and press Shift+EnterA small table with 0, 1 and 2: real Spark answered

Menu names move a little between releases. If a label differs, look for the same idea nearby: Catalog, New, Notebook. "Serverless" in step 5 is the kind of compute Free Edition gives you; the next two sections say what that means.

Your notebook is here. Spark is over there.

You typed one line into a web page and Spark answered. So where did it run?

Not in your browser. Databricks is built in two parts. Think of a restaurant: the front counter takes your order, the kitchen cooks it.

The front counter is the control plane. It holds the web app, your notebooks, the job scheduler and Unity Catalog: the list of every table's name, who may read it, and where its data came from.

The kitchen is the compute plane: the machines where Spark reads and crunches rows.

Your data sits in a third place, cloud object storage. Tables there are Delta Lake tables: Parquet files plus a log of every change.

Where your code, Spark and the data live

Three groups of boxes: the control plane with notebooks, the job scheduler and Unity Catalog; the serverless compute plane with a Spark Connect server and executors; and storage holding Delta tables and volumes. A dashed box shows classic compute in your own cloud account.

Read the three coloured boxes in order: where you type, where Spark runs, where the data rests. Your rows never pass through the control plane, only plans and results do.

Two kinds of kitchen

The compute plane comes in two kinds.

Classic compute is virtual machines in your own cloud account. You choose their size, and your cloud provider bills you for them.

Serverless compute runs in Databricks' account. It starts in seconds, sizes itself, and bills only while work runs.

Either way, Databricks charges for compute in DBUs (Databricks Units) per hour. Free Edition gives you serverless only. That is why the dashed box in the picture is grey.

Remember: the control plane holds your notebook and the catalog. The compute plane runs Spark. The rows stay in storage.

First surprise: the file is not there

You paste the Module 11 code. It reads data/orders.csv, and that path does not exist here. Your laptop's folders did not come with you.

On Databricks, files live in volumes: folders that Unity Catalog governs the same way it governs tables. A file in a volume has a path with slashes, such as /Volumes/workspace/default/raw/orders.csv.

A table gets a dotted name with three parts instead: catalog.schema.table, such as workspace.default.orders.

To make the volume: in Catalog open workspace, then default, choose Create, then Volume, name it raw, open it and use Upload to this volume.

One catalog, two ways to name things

A tree: Unity Catalog holds the workspace catalog and a read-only samples catalog; workspace holds the default schema, which holds the orders table and the raw volume with orders.csv inside it.

Read it top down: catalog, then schema, then a table or a volume. Tables are named with dots, files in a volume with slashes.

Count before you upload

SELECT COUNT(*) AS orders,
  COUNT(DISTINCT customer_id) AS customers,
  MIN(order_ts)::date AS first_day,
  MAX(order_ts)::date AS last_day
FROM orders;

This is the store's own database. Write the four numbers down. After the upload, the same counts on Databricks prove the file arrived whole: Module 1's first habit, now across two systems.

Read the volume, save a table

Runs on Databricks:

orders = spark.read.csv(
    "/Volumes/workspace/default/raw/orders.csv",
    header=True,
    inferSchema=True,
)
print(orders.count())
orders.printSchema()
orders.write.mode("overwrite").saveAsTable("workspace.default.orders")
80
root
 |-- order_id: integer (nullable = true)
 |-- customer_id: integer (nullable = true)
 |-- order_ts: timestamp (nullable = true)
 |-- status: string (nullable = true)
 |-- currency: string (nullable = true)
 |-- updated_at: timestamp (nullable = true)

80 rows, the same as the source. saveAsTable makes a managed table: Unity Catalog decides where its files live and looks after them. You did not pick a format, and you did not need to: a table on Databricks is Delta by default.

The same five numbers

Now Nora's question. Below is the Module 11 code as it runs here, in your browser. Run it and note the five counts.

After it comes the same code in a Databricks notebook. Two small things changed. It reads the table you saved, by its three-part name. And it skips getOrCreate(), because spark already exists in every notebook. (Leaving that line in is harmless: it returns the spark that is already there.)

A notebook cell runs Python unless you say otherwise. Start a cell with %sql when you want SQL.

Here: the Module 11 code

from pyspark.sql import SparkSession, functions as F

spark = SparkSession.builder.getOrCreate()
orders = spark.read.csv('data/orders.csv', header=True, inferSchema=True)

by_status = (orders.groupBy('status')
                   .agg(F.count('*').alias('orders'))
                   .orderBy('status'))
for row in by_status.collect():
    print(row['status'], row['orders'])

This runs on DuckDB behind the PySpark API. Keep the five numbers in view for the next card.

There: the same code on real Spark

Runs on Databricks:

from pyspark.sql import functions as F

orders = spark.table("workspace.default.orders")
by_status = (orders.groupBy("status")
                   .agg(F.count("*").alias("orders"))
                   .orderBy("status"))
by_status.show()
+---------+------+
|   status|orders|
+---------+------+
|cancelled|     9|
|delivered|    29|
|   placed|     8|
| returned|     8|
|  shipped|    26|
+---------+------+

The numbers match. Real Spark right-aligns values and prints null for a missing one; the browser stand-in centres them and prints None. Compare the numbers, never the drawing.

Second surprise: the typo that failed late

You get careless and type orders.select('order_id', 'statsu'). On a laptop's classic PySpark, that line fails at once. Here it runs without a word. The error turns up two cells later.

The reason is how a serverless notebook talks to Spark. Your spark is only a thin client. Each DataFrame call adds a step to a plan and sends nothing. Think of writing a shopping list: nobody checks whether the shop sells an item until you hand the list over.

You hand the list over at an action: count, collect, display or a write. This way of talking to Spark is called Spark Connect.

What Shift+Enter really sends

Three notebook cells build a plan on the client; only the third, an action, sends it to the Spark server, which checks the names, finds the typo, and after the fix runs the plan and returns the result.

  1. Cell 1: a select with a typo. The call adds one step to a plan inside your notebook. Nothing is sent, so nobody has checked the column name.

  2. Cell 2: a filter. The plan grows to two steps. The server still knows nothing about it.

  3. Cell 3: an action. display needs rows, so the whole plan travels to the server, packed as protocol buffers and sent over gRPC.

  4. The server checks the names. It looks for statsu in Unity Catalog, finds no such column and answers with an error. The error lands on cell 3, not on the line with the typo.

  5. Typo fixed, run again. Every name is found. The server optimises the plan, runs it on the executors and streams the rows back as Apache Arrow batches.

Press Next step and watch the Spark server box: it has nothing to do until cell 3 sends the plan. The plan your notebook holds is called an unresolved logical plan, unresolved because no name in it has been checked yet.

Remember: on serverless, nothing is checked until an action sends the plan. When an error points at display or count, read back to the line that built the plan.

The driver is no longer yours

On classic Spark the driver was a program you owned (Lesson 12.1). With Spark Connect the driver moved to the server, where Databricks can share it and resize it for you. So three old habits stop working:

  • No RDDs. There is no SparkContext, so df.rdd and sc.parallelize are gone.
  • No hand caching or tuning. CACHE TABLE and most spark.conf settings are refused.
  • No Spark UI. You read the query profile instead.

One more: Python UDFs run in a sandbox with a fixed 1 GiB memory limit.

Here against there

ThingHere, in the browserOn serverless Databricks
Filesdata/orders.csv in the run folder/Volumes/workspace/default/raw/orders.csv
TablesTemp views and files, gone after the runDelta tables named catalog.schema.table, kept
EngineDuckDB behind the PySpark APIReal Spark through Spark Connect, Photon on
A wrong column nameFails when the query runsFails at the next action, not at the line
RDD API, df.rddNot availableNot supported
TuningNothing to tuneServerless sizes itself; most Spark configs refused
Seeing what ranprint and collect()display(df) and the query profile (no Spark UI)

This is the list to carry when an older job moves to serverless: rewrite RDD code as DataFrame code, drop the cluster tuning, and write an intermediate Delta table where you used to cache.

What free does not include

Free Edition has edges, and one of them sets a floor on run time: at most 5 job tasks run at once across your account.

Say a job has 8 independent tasks of 3 minutes each (made-up numbers):

  • 5 tasks start first and run from minute 0 to 3
  • the last 3 wait, then run from minute 3 to 6

That is 2 waves and 6 minutes, however fast your code is. A paid workspace could run all 8 at once and finish in 3.

8 tasks, 5 at a time

A timeline with five lanes: five tasks run from minute 0 to 3, then the remaining three run from minute 3 to 6.

Each row is one of the 5 slots. Count the columns of bars to get the waves: 2 waves of 3 minutes is 6 minutes.

The trap: treating Free Edition like a work account. Usage sits under a fair-usage quota. Go over it and compute is shut down for the rest of the day (in extreme cases, the month). Your data and settings are kept. And it is for non-commercial use only: never load an employer's or a customer's data into it.

Numbers to remember

ThingIn Free Edition
ComputeServerless only
SQL warehouseOne, size 2X-Small
Job tasks running at onceAt most 5 across the account
PipelinesOne active pipeline of each type
Going over the fair-usage quotaCompute off for the rest of the day (in extreme cases, the month); data and settings kept
LanguagesPython and SQL. No R or Scala
Internet from your codeOutbound only, to a list of trusted domains
WorkspacesOne
Python UDF memory on serverlessA fixed 1 GiB
inferSchema=TrueCosts an extra pass over the file. For a big recurring load, pass an explicit schema
What came beforeCommunity Edition, which Free Edition replaced

At work, Databricks usually has separate catalogs or workspaces for dev and prod, classic job clusters for long steady batches, serverless for bursty or interactive work, and Unity Catalog permissions on every table. Free Edition is the same product with small limits. That makes it the right place to practise the screens and commands interviewers ask about.

What changed at SwiftKart

At 5:05 you send Nora the output: cancelled 9, delivered 29, placed 8, returned 8, shipped 26. The same five numbers, from real Spark.

You add a short list of what will not come along when older jobs move to serverless: RDD code, cluster tuning, and the habit of trusting the line an error points at.

One thing you did not choose today. saveAsTable stored the orders as a Delta table: Parquet files plus a log. Lesson 13.2 opens that log, on the morning a teammate deletes 51 orders by mistake.

In one line

Databricks keeps your notebook and the catalog in a control plane and runs Spark in a compute plane; on serverless your code only sends a plan at an action, files live in /Volumes/... and tables have three-part names.

Interview corner

What is the difference between the control plane and the compute plane, and where does serverless fit?

The control plane is what Databricks runs in its own account: the web app, notebooks, the job scheduler and Unity Catalog metadata. The compute plane is where Spark processes data. Classic compute is VMs in the customer's cloud account, sized by you and billed by the cloud as well as in DBUs; serverless compute runs in Databricks' account, starts in seconds, scales itself and bills DBUs only while work runs. Data stays in object storage either way, as Delta tables.

What changes when a classic-cluster PySpark job moves to serverless?

Serverless runs Spark Connect: the client sends an unresolved plan at each action and the server analyses it, so name errors surface at the action. There is no SparkContext or RDD API, table caching and most Spark configs are not available, the Spark UI is replaced by the query profile, and Python UDFs run in a sandbox with a 1 GiB memory limit. So I rewrite RDD code as DataFrames, remove cluster tuning, test UDF memory and reconcile outputs before switching.

How would you prove a pipeline moved to Databricks produces the same data?

Run the old and new versions on the same input and compare at several levels: row counts per day and per status, distinct key counts, sums of money columns, and a hash total over the key columns (Module 7). Check the schema too, because inferSchema can type a column differently. Only when every reconciliation matches do I switch consumers to the new tables.

Serverless or a classic job cluster for a nightly two-hour batch?

Serverless removes idle time, startup waits and sizing decisions, which suits short, bursty or unpredictable work. A long, steady batch is where classic compute can win: you pick instance types, can use spot instances and libraries or init scripts serverless does not allow. I would run both for a week and compare cost per run from system.billing.usage and the run times, rather than guess.