📖 Scenario: You have just joined a data science team that uses Databricks to analyze big data. Your first task is to get familiar with the Databricks platform by creating a simple dataset, configuring a setting, applying a basic Spark operation, and displaying the result.
🎯 Goal: Build a simple Databricks notebook workflow that creates a dataset, sets a configuration, performs a Spark transformation, and shows the output.
📋 What You'll Learn
Create a Spark DataFrame with specific data
Set a Spark configuration variable
Use a Spark transformation to filter data
Display the filtered DataFrame
💡 Why This Matters
🌍 Real World
Databricks is widely used in companies to process and analyze large datasets quickly using Spark. This project helps you understand the basic workflow of creating data, configuring Spark, transforming data, and viewing results.
💼 Career
Data scientists and data engineers use Databricks daily to prepare data for analysis, build machine learning models, and generate reports. Knowing how to work with DataFrames and Spark configurations is essential for these roles.
Progress0 / 4 steps
1
Create a Spark DataFrame
Create a Spark DataFrame called df with these exact rows: (1, 'Apple'), (2, 'Banana'), (3, 'Cherry'). Use the columns 'id' and 'fruit'.
Apache Spark
Hint
Use spark.createDataFrame with a list of tuples and specify the column names as a list.
2
Set a Spark Configuration
Set the Spark configuration spark.sql.shuffle.partitions to 2 using spark.conf.set.
Apache Spark
Hint
Use spark.conf.set with the key and value as strings.
3
Filter the DataFrame
Create a new DataFrame called filtered_df by filtering df to keep only rows where the id is greater than 1.
Apache Spark
Hint
Use the filter method on df with the condition df.id > 1.
4
Display the Filtered DataFrame
Use filtered_df.show() to display the filtered DataFrame.
Apache Spark
Hint
Call show() on filtered_df to print the table.
Practice
(1/5)
1. What is the main purpose of the Databricks platform?
easy
A. To only store data without processing
B. To combine data storage, processing, and analysis in one platform
C. To replace Apache Spark with a new engine
D. To provide a simple text editor for coding
Solution
Step 1: Understand Databricks platform features
Databricks integrates data storage, processing, and analysis in one place.
Step 2: Compare options with platform purpose
Only To combine data storage, processing, and analysis in one platform correctly describes this combined purpose.
Final Answer:
To combine data storage, processing, and analysis in one platform -> Option B
Quick Check:
Databricks = Unified data platform [OK]
Hint: Remember Databricks is an all-in-one data platform [OK]
Common Mistakes:
Thinking Databricks only stores data
Confusing Databricks with just a code editor
Believing it replaces Apache Spark
2. Which of the following is the correct way to start a cluster in Databricks?
easy
A. Click the 'Start Cluster' button in the Clusters UI
B. Run start_cluster() in a notebook cell
C. Use the command line to type cluster start
D. Clusters start automatically without any action
Solution
Step 1: Recall Databricks cluster management
Clusters are started via the UI by clicking the 'Start Cluster' button.
Step 2: Evaluate other options
Running start_cluster() or command line commands is not standard; clusters do not start automatically.
Final Answer:
Click the 'Start Cluster' button in the Clusters UI -> Option A
Quick Check:
Start clusters via UI button [OK]
Hint: Use the UI button to start clusters, not code commands [OK]
Common Mistakes:
Trying to start clusters with code commands
Assuming clusters start automatically
Confusing cluster start with notebook run
3. Given the following code in a Databricks notebook:
df = spark.range(5) df.show()
What will be the output?
medium
A. A table showing numbers from 0 to 4
B. An error because spark.range is not valid
C. An empty table with no rows
D. A table showing numbers from 1 to 5
Solution
Step 1: Understand spark.range(5)
This creates a DataFrame with numbers starting at 0 up to 4 (5 numbers total).
Step 2: Analyze df.show() output
It displays the DataFrame rows, showing numbers 0,1,2,3,4.
Final Answer:
A table showing numbers from 0 to 4 -> Option A
Quick Check:
spark.range(5) = 0 to 4 [OK]
Hint: spark.range(n) creates numbers from 0 to n-1 [OK]
Common Mistakes:
Thinking range starts at 1
Expecting an error from spark.range
Assuming empty output
4. You run this code in a Databricks notebook:
df = spark.range(3) df.show(5)
But it only shows 3 rows. Why?
medium
A. The cluster is too small to show 5 rows
B. show(5) is invalid syntax and ignored
C. The DataFrame only has 3 rows, so show(5) shows all available rows
D. You must call collect() before show()
Solution
Step 1: Check DataFrame size
spark.range(3) creates 3 rows: 0,1,2.
Step 2: Understand show(5) behavior
show(5) tries to show 5 rows but only 3 exist, so it shows all 3.
Final Answer:
The DataFrame only has 3 rows, so show(5) shows all available rows -> Option C
Quick Check:
show(n) shows up to n rows [OK]
Hint: show(n) displays up to n rows, not more than exist [OK]
Common Mistakes:
Thinking show(5) causes error
Believing cluster size limits show output
Forgetting DataFrame row count
5. You want to analyze a large dataset using Databricks. Which combination of features helps you write code and run it on powerful machines easily?
hard
A. Manual data download and local scripts
B. Only notebooks without clusters
C. Clusters without notebooks
D. Notebooks and clusters
Solution
Step 1: Identify tools for coding and execution
Notebooks let you write code interactively; clusters provide powerful machines to run code.
Step 2: Evaluate options
Only Notebooks and clusters combines both notebooks and clusters, enabling easy coding and execution on powerful resources.
Final Answer:
Notebooks and clusters -> Option D
Quick Check:
Notebooks + clusters = easy code + power [OK]
Hint: Use notebooks for code and clusters for power [OK]
Common Mistakes:
Ignoring clusters and using only notebooks
Trying to run code without clusters
Downloading data manually instead of using platform
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.