0% found this document useful (0 votes)
19 views37 pages

Databricks Notes

Databricks is a cloud-based platform for processing large data sets, primarily through Azure. It offers features like autoscaling, caching, and various cluster types, while integrating with tools like Kafka and Azure Notebooks. PySpark, a Python interface for Apache Spark, enables data processing and machine learning, supporting RDDs, DataFrames, and various algorithms, with advantages and disadvantages compared to other programming models.

Uploaded by

harikumar60020
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views37 pages

Databricks Notes

Databricks is a cloud-based platform for processing large data sets, primarily through Azure. It offers features like autoscaling, caching, and various cluster types, while integrating with tools like Kafka and Azure Notebooks. PySpark, a Python interface for Apache Spark, enables data processing and machine learning, supporting RDDs, DataFrames, and various algorithms, with advantages and disadvantages compared to other programming models.

Uploaded by

harikumar60020
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Define Databricks
Databricks is a cloud-based solution to help process and transform large amounts of data,
offered by Azure.
2. What is Microsoft Azure?
It is a cloud computing platform. The service provider can set up a managed service in
Azure to allow users to get access to the services on demand.
3. What is DBU?
DBU stands for Databricks Unified, which is a Databricks framework for handling resources
and calculating prices.
4. What distinguishes Azure Databricks from Databricks?
Azure Databricks is a joint effort between Microsoft and Databricks to expand predictive
analytics and statistical modeling.
5. What are the benefits of using Azure Databricks?
Azure Databricks comes with many benefits including reduced costs, increased
productivity, and increased security.
6. Can Databricks be used along with Azure Notebooks?
They can be executed similarly but data transmission needs to be coded manually to the
cluster. There is Databricks connect, which can get this integration done seamlessly.
7. What are the various types of clusters present in Azure Databricks?
Azure Databricks has four types of clusters, including Interactive, Job, Low-priority, and
High-priority.
8. What is caching?
The cache refers to the practice of storing information temporarily. When you go to a
website that you visit frequently, your browser takes the information from the cache instead
of the server. This helps save time and reduce the server’s load.
9. Would it be ok to clear the cache?
Yes, it is ok to clear cache as the information is not necessary for any program.
10. What is autoscaling?
Autoscaling is a Databricks feature that will help you automatically scale your cluster in
whichever direction you need.
11. Would you need to store an action’s outcome in a different variable?
It’s not mandatory. It would completely depend on what purpose it would be used.
12. Should you remove unused Data Frames?
Cleaning Data Frames is not required unless you use cache, as this takes up a good
amount of data on the network.
13. What are some issues you can face with Azure Databricks?
You might face cluster creation failures if you don’t have enough credits to create more
clusters. Spark errors are seen if your code is not compatible with the Databricks runtime.
You can come across network errors if it's not configured properly or if you’re trying to get
into Databricks through an unsupported location.
14. What use is Kafka for?
When Azure Databricks gathers data, it establishes connections to hubs and data sources
like Kafka.
15. What use is Databricks file system for?
The Databricks file system gives data durability even after the Azure Databricks node is
eliminated. It’s a distributed file system designed keeping big data workloads in mind.
16. How to troubleshoot issues related to Azure Databricks?
The best place to start with troubleshooting with Azure Databricks is through documentation
which has solutions for a number of common issues. If further assistance is required,
Databricks support can be contacted.
17. Is Azure Key Vault a viable alternative to Secret Scopes?
It’s certainly possible but it needs to be set up before being used.
18. How do you handle Databricks code while working in a team using TFS or
Git?
It’s not possible to work with TFS as it is not supported. You can only work with Git or
distributed Git repository systems. Although it would be fantastic to attach Databricks to
your Git directory, Databricks works like another clone of the project. You should start by
creating a notebook and then committing it to version control. You can then update it.
19. What languages are supported in Azure Databricks?
Languages such as Python, Scala, and R can be used. With Azure Databricks, you can
also use SQL.
Learn the Fundamentals of How Business Works
Executive Certificate In General ManagementEXPLORE PROGRAM

20. Can Databricks be run on private cloud infrastructure?


Currently, you can only run it on AWS and Azure. But Databricks is on open-source Spark.
This means it’s possible to create your own cluster and have it on your own private cloud.
However, you won’t be able to take advantage of all the extensive capabilities you get from
Databricks.
21. Can you administer Databricks using PowerShell?
Officially, you can’t do it. But there are PowerShell modules that you can try out.
22. What is the difference between an instance and a cluster in Databricks?
An instance is a virtual machine that helps run the Databricks runtime. A cluster is a group
of instances that are used to run Spark applications.
23. How to create a Databricks private access token?
To create a private access token, go to the “user profile” icon and select “User setting.”
Here, you’ll need to select the “Access Tokens” tab where you can see the button
“Generate New Token”. Click the button that would create the token.
24. What is the procedure for revoking a private access token?
To revoke the token, go to “user profile” and select “User setting.” Select the “Access
Tokens” tab and click the ‘x’ you’ll find next to the token that you want to revoke. Finally, on
the Revoke Token window, click the button “Revoke Token.”
25. What is the management plane in Azure Databricks?
The management plan is how you manage and monitor your Databricks deployment.
26. What is the control plane in Azure Databricks?
The control plane is responsible for managing Spark applications.
27. What is the data plane in Azure Databricks?
The data plane is responsible for storing and processing data.
28. What is the Databricks runtime used for?
The Databricks runtime is often used to execute the Databricks platform’s collection of
modules.
Learn the Fundamentals of How Business Works
Executive Certificate In General ManagementEXPLORE PROGRAM

29. What use do widgets serve in Databricks?


Widgets can help customize the panels and notebooks by adding variables.
30. What is a Databricks secret?
A secret is a key-value combination that can help keep secret content; it is composed of a
unique key name contained within a secret context. Each scope is limited to 1000 secrets. It
cannot exceed 128 KB in size.
1) What is PySpark? / What do you know about PySpark?
PySpark is a tool or interface of Apache Spark developed by the Apache Spark community
and Python to support Python to work with Spark. This tool collaborates with Apache Spark
using APIs written in Python to support features like Spark SQL, Spark DataFrame, Spark
Streaming, Spark Core, Spark MLlib, etc. It provides an interactive PySpark shell to analyze
structured and semi-structured data in a distributed environment and process them by
providing optimized APIs that help the program to read data from various data sources.
PySpark features are implemented in the py4j library in Python. Due to the availability of the
Py4j library, it facilitates users to work with RDDs (Resilient Distributed Datasets) in the
Python programming language. Python supports many libraries that support big data
processing and machine learning.
You can install PySpark using PyPi by using the following command:
1. pip install pyspark

2) What are the main characteristics of PySpark?


Following are the main four main characteristics of PySpark:
o Nodes are abstracted: The nodes are abstracted in PySpark. It means we cannot access the
individual worker nodes.
o PySpark is based on MapReduce: PySpark is based on the MapReduce model of Hadoop. It
means that the programmer provides the map and the reduced functions.
o APIs for Spark features: PySpark provides APIs for utilizing Spark features.
o Abstracted Network: PySpark provides abstracted networks. It means that the networks are
abstracted in PySpark, and it facilitates only implicit communication.

3) What is RDD in PySpark?


In PySpark, RDD is an acronym that stands for Resilient Distributed Datasets. It is a core data
structure of PySpark. It is a low-level object that is highly efficient in performing distributed
tasks.
Advertisement
The PySpark's RDDs are the elements that can run and operate on multiple nodes to do
parallel processing on a cluster. These are immutable elements. It means that if you once
create an RDD, you cannot change it. RDDs are also fault-tolerant. In the case of any failure,
they recover automatically. We can apply multiple operations on RDDs to achieve a certain
task.

4) What are the key advantages and disadvantages of PySpark?


Following is a list of key advantages and disadvantages of PySpark:
Advantages of PySpark
o PySpark is an easy-to-learn language. You can learn and implement it easily if you know
Python and Apache Spark.
o PySpark is simple to use. It provides parallelized codes that are simple to write.
o Error handling is simple in the PySpark framework. You can easily handle errors and manage
synchronization points
o PySpark is a Python API for Apache Spark. It provides great library support. Python has a
huge library collection for working in data science and data visualization compared to other
languages.
o Many important algorithms are already written and implemented in Spark. It provides many
algorithms in Machine Learning or Graphs.
Disadvantages of PySpark
o PySpark is based on Hadoop's MapReduce model, so sometimes, it becomes challenging to
manage and express problems using the MapReduce model.
o Since Apache Spark was originally written in Scala while using PySpark in Python programs,
they are not as efficient as other programming models. It is approximate 10x times slower
than the Scala programs. Due to this reason, it negatively impacts the performance of heavy
data processing applications.
o The Spark Streaming API in PySpark is not as efficient as Scala. It still requires improvements.
o In PySpark, the nodes are abstracted, and it uses the abstracted network, so it cannot be
used to modify the internal function of the Spark. Scala is preferred in this case.

5) What are the prerequisites to learn PySpark?


PySpark is easy to learn and implement. It doesn't require the expertise of many
programming languages or databases. You can learn it easily if you know a programming
language and framework. Before learning the concept of PySpark, you should learn some
knowledge of Apache Spark and Python. It will be very helpful to learn the advanced
concepts of PySpark.

6) Why are Partitions immutable in PySpark?


In PySpark, every transformation generates a new partition. Partitions use HDFS API to make
partitions immutable, distributed, and fault-tolerant. Partitions are also aware of data
locality.

7) What are the key differences between an RDD, a DataFrame, and


a DataSet?
Following are the key differences between an RDD, a DataFrame, and a DataSet:
RDD
o RDD is an acronym that stands for Resilient Distributed Dataset. It is a core data structure of
PySpark.
o RDD is a low-level object that is highly efficient in performing distributed tasks.
o RDD is best to do low-level transformations, operations, and control on a dataset.
o RDD is mainly used to alter data with functional programming structures than with domain-
specific expressions.
o If you have a similar arrangement of data that needs to be calculated again, RDDs can be
efficiently reserved.
o RDD contains all datasets and DataFrames in PySpark.
DataFrame
o A DataFrame is equivalent to a relational table in Spark SQL. It facilitates the structure like
lines and segments to be seen.
o If you are working on Python, it is best to start with DataFrames and then switch to RDDs if
you want more flexibility.
o One of the biggest disadvantages of DataFrames is Compile Time Wellbeing. For example, if
the information structure is unknown, you cannot control it.
DataSet
o A Dataset is a distributed collection of data. It is a subset of DataFrames.
o Dataset is a newly added interface in Spark 1.6 to provide RDD benefits.
o DataSet consists of the best encoding component. It provides time security in an organized
manner, unlike information edges.
o DataSet provides a greater level of type safety at compile-time. It can be used if you want
typed JVM objects.
o By using DataSet, you can take advantage of Catalyst optimization. You can also use it to
benefit from Tungsten's fast code generation.

8) What do you understand by PySpark SparkContext?


SparkContext acts as the entry point to any spark functionality. When the Spark application
runs, it starts the driver program, and the main function and SparkContext get initiated.
After that, the driver program runs the operations inside the executors on worker nodes. In
PySpark, SparkContext is known as PySpark SparkContext. It uses Py4J (library) to launch a
JVM and then creates a JavaSparkContext. The PySpark's SparkContext is by default
available as 'sc', so it doesn't mean creating a new SparkContext.

9) What is the usage of PySpark StorageLevel?


The PySpark StorageLevel is used to control the storage of RDD. It controls how and where
the RDD is stored. PySpark StorageLevel decides if the RDD is stored on the memory, over
the disk, or both. It also specifies whether we need to replicate the RDD partitions or
serialize the RDD.
Following is the code for PySpark StorageLevel:
1. class [Link]( useDisk, useMemory, useOfHeap, deserialized, replication = 1)

10) What do you understand by data cleaning?


Data cleaning is the process of preparing data by analyzing the data and removing or
modifying data if it is incorrect, incomplete, irrelevant, duplicated, or improperly formatted.

11) What is PySpark SparkConf?


PySpark SparkConf is mainly used if we have to set a few configurations and parameters to
run a Spark application on the local/cluster. In other words, we can say that PySpark
SparkConf is used to provide configurations to run a Spark application.

12) What are the different types of algorithms supported in PySpark?


Different types of algorithms supported in PySpark are:
o [Link]
o [Link]
o [Link]
o [Link]
o [Link]
o [Link]
o [Link]
13) What is SparkCore, and what are the key functions of
SparkCore?
SparkCore is a general execution engine for the Spark platform, including all the
functionalities. It offers in-memory computing capabilities to deliver a good speed, a
generalized execution model to support various applications, and Java, Scala, and Python
APIs that make the development easy.
The main responsibility of SparkCore is to perform all the basic I/O functions, scheduling,
monitoring, etc. It is also responsible for fault recovery and effective memory management.
The key functions of SparkCore are:
o Perform all the basic I/O functions
o Job scheduling
o Monitoring jobs
o Memory management
o Fault-tolerance
o Interaction with storage systems
Note: It also includes additional libraries that can divide the workloads for streaming, machine
learning, and SQL.

14) What do you know about PySpark SparkFiles?


PySpark facilitates users to upload their files using [Link]. Here, sc is our default
SparkContext. We can also get the path of the working directory using [Link].
SparkFiles provides the following types of class methods to resolve the path to the files
added through [Link]():
o get(filename)
o getrootdirectory()

15) What do you know about PySpark serializers?


In PySpark, serialization is a process that is used to conduct performance tuning on Spark.
PySpark supports serializers because we have to continuously check the data sent or
received over the network to the disk or memory. PySpark supports two types of serializers.
They are as follows:
o PickleSerializer: This is used to serialize the objects using Python's PickleSerializer using
class [Link]). This serializer supports almost every Python object.
o MarshalSerializer: The MarshalSerializer is used to perform serialization of objects. This can
be used by using class [Link]. This serializer is way faster than the
PickleSerializer, but it supports only limited types.

16) What is PySpark ArrayType? Give an example to explain it well.


PySpark ArrayType is a collection data type that extends the PySpark's DataType class,
which is the superclass for all kinds. The PySpark ArrayType contains only the same types of
items. The ArraType() method can also be used to construct an instance of an ArrayType.
It accepts two arguments:
o valueType: The valueType should extend the DataType class in PySpark.
o valueContainsNull: It is an optional argument. It specifies whether a value can accept null
and is set to True by default.
Example:
1. from [Link] import StringType, ArrayType
2. arrayCol = ArrayType(StringType(),False)

17) What are the most frequently used Spark ecosystems?


The most frequently used Spark ecosystems are:
o Spark SQL for developers. It is also known as Shark.
o Spark Streaming for processing live data streams.
o Graphx for generating and computing graphs.
o MLlib (also known as Machine Learning Algorithms)
o SparkR to promote R programming language in Spark engine.

18) What machine learning API does PySpark provide?


Just like Apache Spark, PySpark also provides a machine learning API known as MLlib. MLlib
supports the following types of machine learning algorithms:
o [Link]: This machine learning API supports different methods for binary or
multiclass classification and regression analysis such as Random Forest, Decision Tree, Naive
Bayes, etc.
o [Link]: This machine learning API solves clustering problems for grouping entities
subsets with one another depending on similarity.
o [Link]: FPM stands for Frequent Pattern Matching in this machine learning API. This
machine learning API is used to mine frequent items, subsequences, or other structures that
are used for analyzing large datasets.
o [Link]: This machine learning API is used to solve problems on linear algebra.
o [Link]: This machine learning API is used for collaborative filtering and
recommender systems.
o [Link]: This machine learning API is used to support model-based collaborative
filtering where small latent factors are identified using the Alternating Least Squares (ALS)
algorithm used for predicting missing entries.
o [Link]: This machine learning API solves problems by using regression algorithms
that find relationships and variable dependencies.

19) What is PySpark Partition? How many partitions can you make
in PySpark?
PySpark Partition is a method of splitting a large dataset into smaller datasets based on one
or more partition keys. It enhances the execution speed as transformations on partitioned
data run quicker because each partition's transformations are executed in parallel. PySpark
supports both partitioning in memory (DataFrame) and partitioning on disc (File system).
When we make a DataFrame from a file or table, PySpark creates the DataFrame in memory
with a specific number of divisions based on specified criteria.
It also facilitates us to create a partition on multiple columns using partitionBy() by passing
the columns you want to partition as an argument to this method.
Syntax:
1. partitionBy(self, *cols)
In PySpark, it is recommended to have 4x of partitions to the number of cores in the cluster
available for application.

20) What do you understand by PySpark DataFrames?


PySpark DataFrames are the distributed collection of well-organized data. These are the
same as relational databases tables and are placed into named columns. PySpark
DataFrames are better optimized than R or Python programming language because these
can be created from different sources like Hive Tables, Structured Data Files, existing RDDs,
external databases, etc.
The biggest advantage of PySpark DataFrame is that the data in the PySpark DataFrame is
distributed across different machines in the cluster, and the operations performed on this
would be run parallel on all the machines. This facilitates handling a large collection of
structured or semi-structured data of a range of petabytes.

21) What do you understand by "joins" in PySpark DataFrame?


What are the different types of joins available in PySpark?
In PySpark, joins merge or join two DataFrames together. It facilitates us to link two or
multiple DataFrames together.
INNER Join, LEFT OUTER Join, RIGHT OUTER Join, LEFT ANTI Join, LEFT SEMI Join, CROSS
Join, and SELF Join are among the SQL join types PySpark supports. Following is the syntax
of PySpark Join.
Syntax:
1. join(self, other, on=None, how=None)
Parameter Explanation:
The join() procedure accepts the following parameters and returns a DataFrame:
o "other": It specifies the join's right side.
o "on": It specifies the join column's name.
o "how": It is used to specify an option. Options are inner, cross, outer, full, full outer, left, left
outer, right, right outer, left semi, and left anti. The default is inner.
Types of Join in PySpark DataFrame

Join String Equivalent SQL Join

inner INNER JOIN

outer, full, fullouter, full_outer FULL OUTER JOIN

left, leftouter, left_outer LEFT JOIN

right, rightouter, right_outer RIGHT JOIN

cross

anti, leftanti, left_anti

semi, leftsemi, left_semi


22) What is Parquet file in PySpark?
In PySpark, the Parquet file is a column-type format supported by several data processing
systems. By using the Parquet file, Spark SQL can perform both read and write operations.
The Parquet file contains a column type format storage which provides the following
advantages:
o It is small and consumes less space.
o It facilitates us to fetch specific columns for access.
o It follows type-specific encoding.
o It offers better-summarized data.
o It contains very limited I/O operations.

23) What do you understand by a cluster manager? What are the


different cluster manager types supported by PySpark?
In PySpark, a cluster manager is a cluster mode platform that facilitates Spark to run by
providing all resources to worker nodes according to their requirements.
A Spark cluster manager ecosystem contains a master node and multiple worker nodes. The
master nodes provide the worker nodes with the resources like memory, processor
allocation, etc., according to the nodes' requirements with the help of the cluster manager.
PySpark supports the following cluster manager types:
o Standalone: This is a simple cluster manager that comes with Spark.
o Apache Mesos: This cluster manager is used to run Hadoop MapReduce and PySpark apps.
o Hadoop YARN: This cluster manager is used in Hadoop2.
o Kubernetes: This cluster manager is an open-source cluster manager that helps automate
deployment, scaling, and automatic management of containerized apps.
o local: This cluster manager is a mode for running Spark applications on laptops/desktops.

24) Why is PySpark faster than pandas?


PySpark is faster than pandas because it supports the parallel execution of statements in a
distributed environment. For example, PySpark can be executed on different cores and
machines, unavailable in Pandas. This is the main reason why PySpark is faster than pandas.

25) What is the difference between get(filename) and


getrootdirectory()?
The main difference between get(filename) and getrootdirectory() is that the get(filename)
is used to achieve the correct path of the file that is added through [Link]().
On the other hand, the getrootdirectory() is used to get the root directory containing the
file added through [Link]().

26) What do you understand by SparkSession in Pyspark?


In PySpark, SparkSession is the entry point to the application. In the first version of PySpark,
SparkContext was used as the entry point. SparkSession is the replacement of SparkContext
since PySpark version 2.0. After the PySpark version 2.0, SparkSession acts as a starting
point to access all of the PySpark functionalities related to RDDs, DataFrame, Datasets, etc.
It is also a Unified API used to replace the SQLContext, StreamingContext, HiveContext, and
all other contexts in Pyspark.
The SparkSession internally creates SparkContext and SparkConfig according to the details
provided in SparkSession. You can create SparkSession by using builder patterns.

27) What are the key advantages of PySpark RDD?


Following is the list of key advantages of PySpark RDD:
Immutability: The PySpark RDDs are immutable. If you create them once, you cannot
modify them later. You have to create a new RDD whenever you try to apply any
transformation operations on the RDDs.
Fault Tolerance: The PySpark RDD provides fault tolerance features. Whenever an
operation fails, the data gets automatically reloaded from other available partitions. This
provides a seamless experience of execution of the PySpark applications.
Partitioning: When we create an RDD from any data, the elements in the RDD are
partitioned to the cores available by default.
Lazy Evolution: PySpark RDD follows the lazy evolution process. In PySpark RDD, the
transformation operations are not performed as soon as they are encountered. The
operations would be stored in the DAG and are evaluated once it finds the first RDD action.
In-Memory Processing: The PySpark RDD is used to help in loading data from the disk to
the memory. You can persist RDDs in the memory for reusing the computations.

28) Explain the common workflow of a spark program.


The common workflow of a spark program can be described in the following steps:
o In the first step, we create the input RDDs depending on the external data. Data can be
obtained from different data sources.
o After creating the PySpark RDDs, we run the RDD transformation operations such as filter()
or map() to create new RDDs depending on the business logic.
o If we require any intermediate RDDs to reuse for later purposes, we can persist those RDDs.
o Finally, if any action operations like first(), count(), etc., are present, Spark launches it to
initiate parallel computation.

29) How can you implement machine learning in Spark?


We can implement machine learning in Spark by using MLlib. Spark provides a scalable
machine learning record called MLlib. It is mainly used to create machine learning scalable
and straightforward with ordinary learning algorithms and use cases like clustering,
weakening filtering, dimensional lessening, etc.

30) What do you understand by custom profilers in PySpark?


PySpark supports custom profilers. The custom profilers are used for building predictive
models. Profilers are also used for data review to ensure that it is valid, and we can use it in
consumption. When we require a custom profiler, it has to define some of the following
methods:
o stats: This is used to return collected stats of profiling.
o profile: This is used to produce a system profile of some sort.
o dump: This is used to dump the profiles to a specified path.
o dump(id, path): This is used to dump a specific RDD id to the path given.
o add: This is used for adding profile to existing accumulated profile. The profile class has to
be selected at the time of SparkContext creation.

31) What do you understand by Spark driver?


The Spark driver is a plan that runs on the master node of a machine. It is mainly used to
state actions and alterations on data RDDs.

32) What is PySpark SparkJobinfo?


The PySpark SparkJobinfo is used to get information about the SparkJobs that are in
execution.
Following is the code for using the SparkJobInfo:
1. class SparkJobInfo(namedtuple("SparkJobInfo", "jobId stageIds status ")):

33) What are the main functions of Spark core?


The main task of Spark Core is to implement several vital functions such as memory
management, fault-tolerance, monitoring jobs, job setting up, and communication with
storage systems. It also contains additional libraries, built atop the middle that is used to
diverse workloads for streaming, machine learning, and SQL.
The Spark Core is mainly used for the following tasks:
o Fault tolerance and recovery.
o To interact with storage systems.
o Memory management.
o Scheduling and monitoring jobs on a cluster.

34) What do you understand by PySpark SparkStageinfo?


The PySpark SparkStageInfo is used to get information about the SparkStages available at
that time. Following is the code used for SparkStageInfo:
1. class SparkStageInfo(namedtuple("SparkStageInfo", "stageId currentAttemptId name numTa
sks unumActiveTasks" "numCompletedTasks numFailedTasks" )):

35) What is the use of Spark execution engine?


The Apache Spark execution engine is a chart execution engine that facilitates users to
examine massive data sets with a high presentation. You need to detain Spark in the
memory to pick up performance radically if you want data to be manipulated with manifold
stages of processing.

36) What is the use of Akka in PySpark?


Akka is used in PySpark for scheduling. When a worker requests a task to the master after
registering, the master assigns a task to him. In this case, Akka sends and receives messages
between the workers and masters.

37) What do you understand by startsWith() and endsWith()


methods in PySpark?
The startsWith() and endsWith() methods in PySpark belong to the Column class and are
used to search DataFrame rows by checking if the column value starts with some value or
ends with some value. Both are used for filtering data in applications.
o startsWith() method: This method is used to return a Boolean value. It shows TRUE when
the column's value starts with the specified string and FALSE when the match is not satisfied
in that column value.
o endsWith() method: This method is used to return a Boolean value. It shows TRUE when the
column's value ends with the specified string and FALSE when the match is not satisfied in
that column value. Both methods are case-sensitive.

38) What do you understand by RDD Lineage?


The RDD lineage is a procedure that is used to reconstruct the lost data partitions. The
Spark does not hold up data replication in the memory. If any data is lost, we have to
rebuild it using RDD lineage. This is the best use case as RDD always remembers how to
construct from other datasets.

39) Can we create PySpark DataFrame from external data sources?


Yes, we can create PySpark DataFrame from external data sources. The real-time
applications use external file systems like local, HDFS, HBase, MySQL table, S3 Azure, etc.
The following example shows how to create DataFrame by reading data from a csv file
present in the local system:
1. df = [Link]("/path/to/[Link]")
PySpark supports csv, text, avro, parquet, tsv and many other file extensions.

40) What are the main attributes used in SparkConf?


Following is the list of main attributes used in SparkConf:
o set(key, value): This attribute is used for setting the configuration property.
o setSparkHome(value): This attribute enables the setting Spark installation path on worker
nodes.
o setAppName(value): This attribute is used for setting the application name.
o setMaster(value): This attribute is used to set the master URL.
o get(key, defaultValue=None): This attribute supports getting a configuration value of a
key.
li>

41) How can you associate Spark with Apache Mesos?


We can use the following steps to associate Spark with Mesos:
o First, configure the sparkle driver program to associate with Mesos.
o The Spark paired bundle must be in the area open by Mesos.
o After that, install Apache Spark in a similar area as Apache Mesos and design the property
"[Link]" to point to the area where it is introduced.

42) What are the main file systems supported by Spark?


Spark supports the following three file systems:
o Local File system.
o Hadoop Distributed File System (HDFS).
o Amazon S3
43) How can we trigger automatic cleanups in Spark to handle
accumulated metadata?
We can trigger the automatic cleanups in Spark by setting the parameter ' [Link]'
or separating the long-running jobs into dissimilar batches and writing the mediator results
to the disk.

44) How can you limit information moves when working with Spark?
We can limit the information moves when working with Spark by using the following
manners:
o Communicate
o Accumulator factors

45) How is Spark SQL different from HQL and SQL?


Hive is used in HQL (Hive Query Language), and Spark SQL is used in Structured Query
language for processing and querying data. We can easily join SQL table and HQL table to
Spark SQL. Flash SQL is used as a unique segment on the Spark Core motor that supports
SQL and Hive Query Language without changing any sentence structure.

46) What is DStream in PySpark?


In PySpark, DStream stands for Discretized Stream. It is a group of information or gathering
of RDDs separated into little clusters. It is also known as Apache Spark Discretized Stream
and is used as a gathering of RDDs in the grouping. DStreams are based on Spark RDDs
and are used to enable Streaming to flawlessly coordinate with some other Apache Spark
segments like Spark MLlib and Spark SQL.

Q1. The given file has a delimiter ~|. How will you load it as a spark
DataFrame?
Important: Instead of using sparkContext(sc), use sparkSession (spark).
Name ~|Age
Azarudeen, Shahul~|25
Michel, Clarke ~|26
Virat, Kohli ~|28
Andrew, Simond ~|37
George, Bush~|59
Flintoff, David ~|12
Answer- import findspark
[Link]()
from [Link] import Sparksession, types
spark = [Link]("local").appliame("scenario based")\
-getorcreate()
sc=[Link]
[Link]("[Link]")
[Link](truncate=0)
header=[Link]()[0]
schema=[Link](-')
df_imput=[Link](df['value'] l= header).[Link](lambda x: x[0]. split('-|')).toDF (schema)
df_input.show(truncate=0)

Q2. How will you merge two files – File1 and File2 – into a single
DataFrame if they have different schemas?
File -1:
Name|Age
Azarudeen, Shahul|25
Michel, Clarke|26
Virat, Kohli|28
Andrew, Simond|37
File -2:
Name|Age|Gender
Rabindra, Tagore |32|Male
Madona, Laure | 59|Female
Flintoff, David|12|Male
Ammie, James| 20|Female
Answer- import findspark
[Link]()
from [Link] import SparkSession, types
spark = [Link]("local").appName('Modes of Dataframereader')\
.getorCreate()
sc=[Link]
df1=[Link]("delimiter","|").csv('[Link]')
df2=[Link]("delimiter","|").csv("[Link]",header=True)
from [Link] import lit
df_add=[Link]("Gender",lit("null"))
df_add. union(df2).show()
For the Union-
from [Link] import *
schema=StructType(
[
StructField("Name",StringType(), True),
StructField("Age",StringType(), True),
StructField("Gender",StringType(),True),
]
)
df3=[Link]("delimiter","|").csv("[Link]",header=True, schema=schema)
df4=[Link]("delimiter","|").csv("[Link]", header=True, schema=schema)
[Link](df4).show()

Q3. Examine the following file, which contains some corrupt/bad data.
What will you do with such data, and how will you import them into a
Spark Dataframe?
Emp_no, Emp_name, Department
101, Murugan, HealthCare
Invalid Entry, Description: Bad Record entry
102, Kannan, Finance
103, Mani, IT
Connection lost, Description: Poor Connection
104, Pavan, HR
Bad Record, Description: Corrupt record
Answer-
import findspark
[Link]()
from pyspark. sql import Sparksession, types
spark = [Link]("local").appName( "Modes of Dataframereader')\
.getorcreate()
sc=spark. sparkContext
from [Link] import *
schm structiype([
structField("col_1",stringType(), True),
StructField("col_2",stringType(), True),
structrield("col",stringtype(), True),
])
df=[Link]("mode", "DROPMALFORMED").csv('[Link]', header=True,
schema=schm)
df. show()

Q4. Consider a file containing an Education column that includes an


array of elements, as shown below. Using Spark Dataframe, convert each
element in the array to a record.
Name| Age | Educațion
Azar|25| MBA,BE,HSC
Hari|32|
Kumar|35|ME,BE,Diploma
Answer-
import findspark
[Link]()
from [Link] import SparkSession, types
spark = [Link]("local").appName('scenario based')\
.getorCreate()
sc=[Link]
in_df=[Link]("delimiter","|").csv("[Link]", header-True)
in_df.show()
from [Link] import posexplode_outer, split
in_df.withColumn("Qualification", explode_outer(split("Education",","))).show()
in_df.select("*", posexplode_outer(split("Education",","))).withColumnRenamed ("col",
"Qualification").withColumnRenamed ("pos", "Index").drop(“Education”).show()
Q5. Give the output for the following-
[Link]:
101,Azar,finance
102,Mani,HR
103,Raj,IT
a. in_rdd=[Link]('[Link]')
map_rdd=in_rdd.map(lambda x: [Link](','))
map_rdd.count()
b. in_rdd=[Link]('[Link]')
map_rdd=in_rdd.flatMap(lambda x: [Link](','))
map_rdd.count()
Answer-
a. import findspark
[Link]()
from [Link] import SparkSession
spark=[Link]("local").appName( "map").getOrCreate()
sc=[Link]
in_rdd=[Link]('[Link]')
map_rdd=in_rdd.map(lambda x: [Link](','))
map_rdd.collect()
map_rdd.count ()
For the above code, the output is 3.
b. import findspark
[Link]()
from [Link] import SparkSession
spark=[Link]("local").appName( "map").getOrCreate()
sc=[Link]
in_rdd=[Link]('[Link]')
flat_map_rdd=in_rdd.flatMap(lambda x: [Link](','))
for i in flat_map_rdd.collect():
print(i)
in_rdd.collect()
flat_map_rdd.count()
For the above code, the output is 9.

Capgemini PySpark Interview Questions


Q1. What are SparkFiles in Pyspark?
PySpark provides the reliability needed to upload our files to Apache Spark. This is
accomplished by using [Link], where 'sc' stands for SparkContext. We use [Link]
to acquire the directory path.
We use the following methods in SparkFiles to resolve the path to the files added using
[Link]():
 get(filename),
 getrootdirectory()

Q2. What is SparkConf in PySpark? List a few attributes of SparkConf.


SparkConf aids in the setup and settings needed to execute a spark application locally or in
a cluster. To put it another way, it offers settings for running a Spark application. The
following are some of SparkConf's most important features:
 set(key, value): This attribute aids in the configuration property setting.
 setSparkHome(value): This feature allows you to specify the directory where Spark
will be installed on worker nodes.
 setAppName(value): This element is used to specify the name of the application.
 setMaster(value): The master URL may be set using this property.
 get(key, defaultValue=None): This attribute aids in the retrieval of a key's
configuration value.

Q3. What is the key difference between list and tuple?


The primary difference between lists and tuples is that lists are mutable, but tuples are
immutable.
When a Python object may be edited, it is considered to be a mutable data type. Immutable
data types, on the other hand, cannot be changed.
Here’s an example of how to change an item list into a tuple-
list_num[3] = 7
print(list_num)
tup_num[3] = 7
Output:
[1,2,5,7]
Traceback (most recent call last):
File "python", line 6, in
TypeError: 'tuple' object doesnot support item assignment
We assigned 7 to list_num at index 3 in this code, and 7 is found at index 3 in the output.
However, we set 7 to tup_num at index 3, but the result returned a type error. Because of
their immutable nature, we can't change tuples.

Q4. What do you understand by errors and exceptions in Python?


There are two types of errors in Python: syntax errors and exceptions.
Syntax errors are frequently referred to as parsing errors. Errors are flaws in a program that
might cause it to crash or terminate unexpectedly. When a parser detects an error, it repeats
the offending line and then shows an arrow pointing to the line's beginning.
Exceptions arise in a program when the usual flow of the program is disrupted by an
external event. Even if the program's syntax is accurate, there is a potential that an error will
be detected during execution; nevertheless, this error is an exception. ZeroDivisionError,
TypeError, and NameError are some instances of exceptions.

Q5. What are the most significant changes between the Python API
(PySpark) and Apache Spark?
PySpark is a Python API created and distributed by the Apache Spark organization to make
working with Spark easier for Python programmers. Scala is the programming language
used by Apache Spark. It can communicate with other languages like Java, R, and Python.
Also, because Scala is a compile-time, type-safe language, Apache Spark has several
capabilities that PySpark does not, one of which includes Datasets. Datasets are a highly
typed collection of domain-specific objects that may be used to execute concurrent
calculations.

Q6. Define SparkSession in PySpark. Write code to create SparkSession


in PySpark
Spark 2.0 includes a new class called SparkSession ([Link] import SparkSession). Prior
to the 2.0 release, SparkSession was a unified class for all of the many contexts we had
(SQLContext and HiveContext, etc). Since version 2.0, SparkSession may replace SQLContext,
HiveContext, and other contexts specified before version 2.0. It's a way to get into the core
PySpark technology and construct PySpark RDDs and DataFrames programmatically. Spark
is the default object in pyspark-shell, and it may be generated programmatically with
SparkSession.
In PySpark, we must use the builder pattern function builder() to construct SparkSession
programmatically (in [Link] file), as detailed below. The getOrCreate() function retrieves an
already existing SparkSession or creates a new SparkSession if none exists.
spark=[Link]("local[1]") \
.appName('ProjectPro') \
.getOrCreate()

Q7. Suppose you encounter the following error message while running
PySpark commands on Linux-
ImportError: No module named py4j.java_gateway
How will you resolve it?
Py4J is a Java library integrated into PySpark that allows Python to actively communicate
with JVM instances. Py4J is a necessary module for the PySpark application to execute, and
it may be found in the $SPARK_HOME/python/lib/py4j-*-[Link] directory.
To execute the PySpark application after installing Spark, set the Py4j module to the
PYTHONPATH environment variable. We’ll get an ImportError: No module named
py4j.java_gateway error if we don't set this module to env.
So, here’s how this error can be resolved-
export SPARK_HOME=/Users/abc/apps/spark-3.0.0-bin-hadoop2.7
export PYTHONPATH=$SPARK_HOME/python:$SPARK_HOME/python/build:
$SPARK_HOME/python/lib/[Link]:$PYTHONPATH
Put these in .bashrc file and re-load it using source ~/.bashrc
The py4j module version changes depending on the PySpark version we’re using; to
configure this version correctly, follow the steps below:
export PYTHONPATH=${SPARK_HOME}/python/:$(echo ${SPARK_HOME}/python/lib/py4j-*-
[Link]):${PYTHONPATH}
Use the pip show command to see the PySpark location's path- pip show pyspark
Use the environment variables listed below to fix the problem on Windows-
set SPARK_HOME=C:\apps\opt\spark-3.0.0-bin-hadoop2.7
set HADOOP_HOME=%SPARK_HOME%
set PYTHONPATH=%SPARK_HOME%/python;%SPARK_HOME%/python/lib/py4j-0.10.9-
[Link];%PYTHONPATH%

Q8. Suppose you get an error- NameError: Name 'Spark' is not Defined
while using spark. createDataFrame(), but there are no errors while using
the same in Spark or PySpark shell. Why?
Spark shell, PySpark shell, and Databricks all have the SparkSession object 'spark' by default.
However, if we are creating a Spark/PySpark application in [Link] file, we must manually
create a SparkSession object by using builder to resolve NameError: Name 'Spark' is not
Defined.
# Import PySpark
import pyspark
from [Link] import SparkSession
#Create SparkSession
spark = [Link]
.master("local[1]")
.appName("[Link]")
.getOrCreate()
If you get the error message 'No module named pyspark', try using findspark instead-
#Install findspark
pip install findspark
# Import findspark
import findspark
[Link]()
#import pyspark
import pyspark
from [Link] import SparkSession

Q9. What are the various types of Cluster Managers in PySpark?


Spark supports the following cluster managers:
 Standalone- a simple cluster manager that comes with Spark and makes setting up a
cluster easier.
 Apache Mesos- Mesos is a cluster manager that can also run Hadoop MapReduce
and PySpark applications.
 Hadoop YARN- It is the Hadoop 2 resource management.
 Kubernetes- an open-source framework for automating containerized application
deployment, scaling, and administration.
 local – not exactly a cluster manager, but it's worth mentioning because we use
"local" for master() to run Spark on our laptop/computer.

Q10. Explain how Apache Spark Streaming works with receivers.


Receivers are unique objects in Apache Spark Streaming whose sole purpose is to consume
data from various data sources and then move it to Spark. By streaming contexts as long-
running tasks on various executors, we can generate receiver objects.
There are two different kinds of receivers which are as follows:
 Reliable receiver: When data is received and copied properly in Apache Spark
Storage, this receiver validates data sources.
 Unreliable receiver: When receiving or replicating data in Apache Spark Storage,
these receivers do not recognize data sources.
You can refer to GitHub for some of the examples used in this blog.
Become a data engineer and put your skills to the test! But the problem is, where do you
start? Broadening your expertise while focusing on an advanced understanding of certain
technologies or languages is a good idea. There is no better way to learn all of the
necessary big data skills for the job than to do it yourself. ProjectPro provides a customised
learning path with a variety of completed big data and data science projects to assist you in
starting your career as a data engineer.

FAQs
1. Is PySpark the same as Spark?
No. PySpark is Python API for Spark. PySpark allows you to create applications using Python
APIs.
2. What is PySpark, and how it works?
PySpark is a Python API for Apache Spark. It lets you develop Spark applications using
Python APIs, but it also includes the PySpark shell, which allows you to analyze data in a
distributed environment interactively. Most of Spark's capabilities, such as Spark SQL,
DataFrame, Streaming, MLlib (Machine Learning), and Spark Core, are supported by
PySpark.

3. Is PySpark a Big Data tool? Does PySpark require Spark?


Yes, PySpark is a faster and more efficient Big Data tool.
PySpark is a Python Spark library for running Python applications with Apache Spark
features. Hence, it cannot exist without Spark.

4. Is PySpark easy to learn?


PySpark is easy to learn for those with basic knowledge of Python, Java, etc.

5. How long does it take to learn PySpark?


One week is sufficient to learn the basics of the Spark Core API if you have significant
knowledge of object-oriented programming and functional programming.

6. What is the best way to learn PySpark? Is PySpark a


framework?
PySpark is an open-source framework that provides Python API for Spark.
You should start by learning Python, SQL, and Apache Spark. Also, there are numerous
PySpark courses and tutorials on Udemy, YouTube, etc. But, you must gain some hands-on
experience by working on real-world projects available on GitHub, Kaggle, ProjectPro, etc.
Easy Level Interview Question
In this section, we have provided some Easy Level Questions with answers on Azure
Databricks that can be asked during the interview.
[Link] are databricks?

Databricks is a company founded in 2013 and headquartered in San Francisco, California.


It is the creator of the Apache Spark-based platform called "Databricks", which is a cloud-
based platform for data engineering, machine learning, and collaborative data science.
Databricks provides a collaborative environment for data engineers, data scientists, and
business analysts to work together on data projects. It offers a web-based notebook
environment, which makes it easy to develop, run, and share data analysis projects.
The platform also provides tools for ingesting, transforming, and preparing data and
advanced analytics capabilities such as graph processing, time-series analysis, and
geospatial analysis.

2. What is Azure Databrick?

Azure Databricks is a tool that helps you work with and analyze big data in the cloud. It's
like an online notebook where you can store and run your data projects. You can use it to
import data from different sources, clean and process the data, and then use that data to
get insights and make decisions. It also has features for building and training machine
learning models.
Think of Azure Databricks as a tool that makes working with big data easier and more
efficient. It provides a secure and collaborative environment where you can work with
others on your data projects and extract meaningful insights from the data.

3. What are the advantages of using Azure Databricks?

Azure Databricks is a powerful platform for processing big data and provides several
advantages, including:

 Scalability: Azure Databricks allows you to quickly and easily scale your cluster
resources up or down as needed, making it easy to handle large data sets and meet
your computing needs.

 Integration with Azure services: Azure Databricks integrates seamlessly with other
Azure services, such as Azure Blob Storage, Azure Data Lake Storage, and Azure
SQL Database, allowing you to store, access, and analyze your data easily.

 Apache Spark-based: Azure Databricks is built on Apache Spark, a powerful and


widely used open-source big data processing framework. This allows you to leverage
Spark's rich ecosystem of libraries and tools to process and analyze your data

Must Read Apache Server

4. Define caching.

The term cache refers to the practise of temporarily storing information. When you visit a
frequently visited website, your browser retrieves the information from the cache rather than
the server. This saves time and reduces the load on the server. This is precisely known as
caching.

5. Is it safe to clear the cache?


Yes, clearing the cache is acceptable because any program does not require the
information.

6. Is it necessary to store the outcome of an action in a different variable?

It is not required to store the outcome of an action in a different variable. It would be entirely
dependent on the intended use.

7. Should you get rid of any unused Data Frames?

Cleaning Data Frames is not necessary unless you use a cache, which consumes a
significant amount of data on the network.

8. How do you troubleshoot Azure Databricks issues?

The best place to begin troubleshooting with Azure Databricks is with the documentation,
which contains solutions to a variety of common issues. Databricks support can be
contacted if additional assistance is required.

9. Is Azure Key Vault a viable replacement for Secret Scopes?

Azure Key Vault can be used as a replacement for secret scopes in Azure DevOps, but it
depends on your specific use case and requirements. In general, if you need to store
secrets that you need to access from multiple Azure DevOps organizations or other cloud-
based services, you may find Azure Key Vault more convenient.
However, secret scopes may be a more convenient solution if you only need to manage
secrets for a single Azure DevOps organization and don't need to access them from other
services.

10. What languages does Azure Databricks support?

Python, Scala, and R are examples of programming languages that can be used. SQL can
be used with Azure Databricks as well.
Click on the following link to read further: Javascript Interview Questions and Answers
Medium-Level Interview Questions
In this section, we have provided some Medium Level Questions with answers on Azure
Databricks that can be asked during the interview.
11. What are the major features of Azure Databricks?

Some key features of Azure Databricks include:

 Collaborative Workspaces: Azure Databricks provides a collaborative environment


for data engineers, data scientists, and business analysts to work together on the same
project.

 Data Ingestion and Preparation: It provides tools for ingesting and transforming data
from various sources, including cloud data stores like Azure Data Lake Storage and
relational databases like Azure SQL Database.

 Machine Learning and AI: Azure Databricks provides a platform for building and
deploying machine learning models, with integrations for popular machine learning
frameworks like TensorFlow and PyTorch.
 Advanced Analytics: It supports advanced analytics, including graph processing,
time-series, and geospatial analysis.

12. What are some issues you can face with Azure Databricks?

Like any technology platform, Azure Databricks can face certain issues you need to be
aware of.
Some common issues include:

 Cost: Azure Databricks can be expensive, especially if you have large data sets and
need to provision a large cluster to process them. Careful planning and management of
your cluster resources are important to keep costs under control.

 Complexity: While Azure Databricks provides a lot of powerful features, the platform
can also be complex to set up and use, especially if you're new to Apache Spark and
big data processing. This can make it challenging for some users to get started and get
the most out of the platform.

 Integration with other tools: Integrating Azure Databricks with other tools and
technologies can also be challenging, especially if those tools are not natively
supported by the platform. You may need to write custom code or use third-party
solutions to connect Databricks to other systems.

 Performance: Performance can also be an issue with Azure Databricks, especially if


you have large data sets or complex queries. You may need to tune your cluster
configuration or write optimized Spark code to ensure optimal performance.

 Data security: Securing and managing sensitive data can be challenging in any big
data platform, and Azure Databricks is no exception. You'll need to carefully plan and
implement security measures, such as encryption, access controls, and data masking,
to keep your data secure.
13. In Databricks, what is the difference between an instance and a cluster?

In Azure Databricks, an instance is a single virtual machine (VM) that runs Apache Spark,
and a cluster is a collection of instances that work together to process and analyze data.

An instance provides the computational power and memory needed to run Spark jobs and
store data in memory. You can run multiple instances in parallel to process large data sets,
and each instance can be used to run multiple Spark tasks in parallel.
A cluster, on the other hand, is a collection of instances that work together as a single unit
to process and analyze data. When you create a cluster, you specify the number of
instances you want to include, as well as the amount of memory and CPU resources each
instance should have.
In short, an instance is a single unit of computational power in Databricks, while a cluster is
a group of instances that work together to process big data.

14. What is the management plane in Azure Databricks?

The management plane in Azure Databricks refers to the set of features and tools that are
used to manage and configure the platform.
It provides a set of tools and features that you can use to manage your Spark clusters,
Spark jobs, libraries, secrets, and configurations, ensuring that your big data processing
runs smoothly and effectively.

15. What is the control plane in Azure Databricks?

The control plane in Azure Databricks refers to the underlying infrastructure and
components that manage and orchestrate the processing of big data.
It provides the underlying infrastructure and components that run big data processing and
makes it possible to process and analyze large data sets efficiently and effectively.
Spark applications are managed by the control plane.

16. What exactly is the data plane in Azure Databricks?

The data plane in Azure Databricks refers to the components responsible for
the storage, processing, and retrieval of data within the platform.
This includes features like Databricks file system (DBFS), tables, and Delta lake for storing
data, as well as the Spark engine for processing it.
In simple terms, the data plane provides a foundation for data management and data
processing in Azure Databricks, making it possible to store, process, and analyze large
amounts of data in a fast and efficient manner. This is the part of Azure Databricks that is
responsible for handling and transforming the raw data into actionable insights.
By using the data plane in Azure Databricks, you can simplify the process of working with
big data, as well as reduce the time it takes to turn data into meaningful insights.
Additionally, the data plane provides a variety of tools and features to help you manage and
process data, making it possible to work with data at scale.

17. What is the use of Kafka in Azure Databricks?

Apache Kafka is an open-source, distributed streaming platform that can be used in Azure
Databricks to ingest, process, and store large amounts of real-time data. In Azure
Databricks, you can use Kafka as a source or sink for data, which enables you to build
streaming data pipelines to process data in real-time.

18. What is the major reason behind using Kafka in Azure Databricks?

Kafka is used in Azure Databricks to provide a scalable and reliable way to stream data into
the platform. You can use it to publish real-time data streams, such as logs, events, or
metrics, to a Kafka cluster, and then use Spark Streaming to process and analyze the data.
Additionally, you can use Kafka to store the processed data in Delta Lake, which provides a
scalable and reliable data lake for big data.

19. What are some of the key use cases of Kafka in Azure Databricks?

Some of the key use cases of Kafka in Azure Databricks include:


 Real-time data processing: By using Spark Streaming in Azure Databricks, you can
process real-time data from a Kafka stream in near real-time. This enables you to gain
real-time insights from your data.

 Data integration: You can use Kafka to integrate data from multiple sources and
stream it into Azure Databricks for processing and analysis. This can help you build a
comprehensive data pipeline for big data.

 Event-driven architecture: You can use Kafka to publish events, such as changes to
data or user interactions, and then process these events in real-time using Spark
Streaming in Azure Databricks.

20. What is the benefit of using Kafka in Azure Databricks?

The use of Kafka in Azure Databricks enables you to build scalable, reliable, and high-
performance data pipelines for big data, helping you to turn real-time data into actionable
insights.
Hard-Level Interview Questions
In this section, we have provided some Hard Level Questions with answers on Azure
Databricks that can be asked during the interview.
21. What is DBU in Databricks?

In Databricks, "DBU" is a unit of measurement for Databricks cluster usage, specifically for
resource allocation and billing purposes. A DBU is a blended unit of compute and memory
resources, representing the computational power of a virtual machine. Databricks
customers can provision and run their Apache Spark workloads on Databricks clusters, and
their usage of those clusters is measured and billed in DBUs.
DBUs allow Databricks customers to pay for only the resources they use, rather than
having to allocate and pay for entire virtual machines. This makes it easier for customers to
scale their cluster resources up or down as needed without having to worry about the
complexities of managing individual virtual machine instances.

22. How would you use Azure Databricks to process big data?

Azure Databricks is a powerful platform for processing big data, and here's a high-level
overview of how you might use it:

 Provision a Databricks cluster: To get started, you'll need to create a Databricks


cluster, which is a collection of virtual machines that run Apache Spark. You can
provision clusters in the Azure portal or through the Databricks REST API.

 Upload your data: You can upload your data to Databricks by storing it in Azure data
stores such as Azure Blob Storage, Azure Data Lake Storage, or Azure SQL Database
and then accessing it from your Databricks cluster.

 Transform your data: Once your data is uploaded, you can use Spark SQL, Spark
Streaming, and other Spark libraries to transform it into a suitable form for analysis.
Depending on your needs, this might involve filtering, aggregating, or pivoting your
data.

 Analyze your data: Databricks provides a wide range of analytics tools and machine
learning algorithms that you can use to analyze your data. For example, you might use
Spark MLlib to train machine learning models or use Databricks' built-in SQL analytics
functions to perform ad-hoc queries on your data.

 Visualize your results: Finally, you can use Databricks' built-in visualization tools, or
export your results to other visualization tools, such as Power BI, to view and explore
your results.
23. Can you give an example of a data analysis project you've worked on using Azure
Databricks?

Sample Answer: Imagine you have a retail company that wants to analyze customer
purchase data to understand their buying behavior and improve their sales and marketing
strategies.
You could use Azure Databricks to perform the following steps:
 Data ingestion: You can use Azure Databricks to ingest the customer purchase data
from various sources, such as a relational database, Amazon S3, or Kafka.

 Data cleaning and transformation: You can use Spark in Azure Databricks to
perform data cleaning and transformation, such as removing missing values,
duplicates, and converting data types.

 Data storage: You can store the cleaned and transformed data in Delta Lake, which
provides a scalable and reliable data lake for big data.

 Data analysis: You can use Spark SQL, machine learning libraries, and visualization
tools in Azure Databricks to perform data analysis and uncover insights. For example,
you can use Spark SQL to aggregate data by customer segments and compute key
metrics, such as the average purchase value and the frequency of purchases. You can
also use machine learning algorithms, such as regression or clustering, to predict
customer behavior and segment customers based on their purchase history.

 Data visualization: You can use the built-in visualization tools in Azure Databricks to
create interactive dashboards, charts, and graphs to visualize the results of your
analysis.

Using Azure Databricks, you can simplify the process of working with big data and turn the
customer purchase data into actionable insights that can help the retail company improve
its sales and marketing strategies.

24. How would you ensure the security of sensitive data in an Azure Databricks
environment?

Ensuring the security of sensitive data in an Azure Databricks environment is crucial to


protecting sensitive information and complying with data protection regulations.
Here are some steps that you can follow to secure sensitive data in Azure Databricks:
 Access control: You can use Azure Active Directory (AD) to manage access to Azure
Databricks and control who can access the data. You can also use role-based access
control (RBAC) to assign different access levels to users and groups.

 Encryption: You can use encryption to protect sensitive data at rest and in transit.
Azure Databricks supports encryption at rest using Azure Key Vault and Azure Storage
Service Encryption. You can also encrypt data in transit using SSL/TLS.
 Data masking: You can use data masking techniques, such as anonymization,
pseudonymization, and encryption, to protect sensitive data fields, such as social
security numbers and credit card numbers.

 Network security: You can use virtual networks and firewall rules to secure the
network connection between Azure Databricks and other Azure services and control
access to the data from the internet.

 Auditing and monitoring: You can use Azure Monitor to track activities and detect
potential security threats in Azure Databricks. You can also use Azure Log Analytics to
analyze logs and monitor the security of the data.

25. Can you explain the concept of collaborative workspaces in Azure Databricks?

Collaborative workspaces in Azure Databricks provide a collaborative environment for data


engineers, data scientists, and business analysts to work together on big data projects.
With collaborative workspaces, you can share notebooks, data, and models and collaborate
in real-time on the same project.
Collaborative workspaces in Azure Databricks provide a unified environment for data
engineers, data scientists, and business analysts to work together on big data projects,
helping to simplify the collaboration process and ensure that everyone has access to the
latest data, models, and insights.

26. Which of these two options, a Databricks instance or a cluster, is superior?

In general, if you're looking for a fully managed platform for your big data and AI workloads,
a Databricks instance may be the superior option. If you're looking for a scalable and
flexible platform for running Spark jobs, a cluster may be the superior option.
Ultimately, the choice between a Databricks instance and a cluster will depend on your
specific use case and requirements. You may find that using both a Databricks instance
and clusters is the best solution for your needs.

27. Which cloud service category does Microsoft's Azure Databricks fall under: SaaS,
PaaS, or IaaS?

Microsoft Azure Databricks belongs to the Platform as a Service (PaaS) category of cloud
services.

 In PaaS, the cloud provider manages the infrastructure and provides a platform for
building, deploying, and running applications and services. The provider takes care of
the underlying infrastructure, such as servers, storage, and networking, allowing
customers to focus on building and deploying their applications and services.

 With Azure Databricks, customers can build and run big data and machine learning
workloads on a fully managed cloud-based platform that runs on top of Apache Spark.

 The platform provides a suite of tools and services for data processing, machine
learning, and collaboration, and the underlying infrastructure is managed by Microsoft.

 By using a PaaS like Azure Databricks, customers can avoid the costs and complexity
of managing their own infrastructure and focus on building and deploying their
applications and services.

28. What are the differences between Microsoft Azure Databricks and Amazon Web
Services Databricks?
Microsoft Azure Databricks and Amazon Web Services (AWS) Databricks are both cloud-
based platforms for data engineering, machine learning, and analytics that run on top of
Apache Spark. However, there are some differences between the two platforms.
Cloud Provider

The main difference between the two platforms is the underlying cloud provider. Microsoft
Azure Databricks runs on the Microsoft Azure cloud platform, while AWS Databricks runs
on the Amazon Web Services cloud platform.

Integration with Other Services

Another difference is the level of integration with other cloud services offered by the
provider. Microsoft Azure Databricks integrates with other Azure services, such as Azure
Active Directory, Azure Blob Storage, and Azure Data Lake Storage. AWS Databricks
integrates with other AWS services, such as Amazon S3, Amazon DynamoDB, and
Amazon Redshift.

Pricing

The pricing for the two platforms can also differ, depending on the specific services used
and the amount of resources consumed. Customers should compare the pricing for both
platforms based on their specific use case and requirements.

29. What is Serverless Database Processing in Azure?

Serverless database processing in Azure refers to the ability to process database


workloads without having to provision and manage infrastructure. This allows you to scale
your database processing resources as needed, without having to worry about capacity
planning and management.
 In Azure, serverless database processing is provided by Azure Functions and Azure
Synapse Analytics (formerly SQL Data Warehouse).

 With Azure Functions, you can create serverless functions that can be triggered by
various events, including database updates. This allows you to process data in real-
time as it arrives in your database, without having to provision and manage
infrastructure.

 With Azure Synapse Analytics, you can process large amounts of data using a
combination of on-demand and provisioned resources.

 Azure Synapse provides a serverless experience for big data and data warehousing
workloads, allowing you to scale your processing resources as needed without having
to worry about capacity planning and management.

30. What is the most efficient way to migrate data from an on-premises database to
one hosted on Microsoft Azure?

The most efficient way to move information from an on-premises database to one hosted on
Microsoft Azure will depend on the specific requirements and constraints of the migration.
However, some of the most common methods for migrating data from on-premises
databases to Azure include:
Azure Data Factory: Azure Data Factory is a cloud-based data integration service that can
be used to copy data from an on-premises database to Azure. This method provides a
simple and efficient way to move data to Azure, and supports various data sources and
formats.

Azure Database Migration Service: Azure Database Migration Service is a fully managed
service that simplifies and automates the process of moving on-premises databases to
Azure. This service supports various database platforms, including SQL Server, Oracle,
and MySQL, and provides a simple and efficient way to move large amounts of data to
Azure.

Backup and Restore: You can also use backup and restore to move your on-premises
database to Azure. This method involves taking a backup of your on-premises database
and restoring it to a database in Azure. This method provides a simple and reliable way to
move your data to Azure, but may require additional effort to manage the backup and
restore process.

BCP (Bulk Copy Program): BCP is a command-line tool that is used to import or export
large amounts of data to or from a SQL Server database. This method can be used to move
data from an on-premises SQL Server database to an Azure SQL database.

Azure Arc: Azure Arc is a new service that allows you to manage resources running on-
premises, in other clouds, or at the edge, from a single control plane in Azure. You can use
Azure Arc to move information from an on-premises database to an Azure database, by first
deploying the database on-premises and then migrating it to Azure.

Each of these methods has its own pros and cons, and the best method for your migration
will depend on your specific requirements and constraints. You should carefully consider
the data volumes, frequency of updates, complexity of the data, and other requirements
when choosing a migration method

1. Is it possible to combine Databricks and Azure Notebooks?


They operate similarly, but data transfer to the cluster requires manual coding. This Integration
is now easily possible thanks to Databricks Connect. On behalf of Jupyter, Databricks makes a
number of improvements that are specific to Databricks.
2. What exactly does coaching entail?
Temporary holding is referred to as the cache. The process of temporarily storing information is
referred to as caching. You'll save time and lessen the load on the server when you come back
to a frequently visited website because the browser will retrieve the data from the cache rather
than from the server.
3. What different types of caching are there?
There are four types of caching that stand out:
 Information caching
 Web page caching
 Widespread caching
 Output or application caching.
[ Learn Complete Azure Databricks Tutorial ]
4. Should you ever remove and clean up any leftover Data Frames?
Cleaning Frames is not necessary unless you use cache(), which will use a lot of network
bandwidth. You should probably clean up any large datasets that are being cached but aren't
being used.
5. What different ETL operations does Azure Databricks carry out on data?
The various ETL processes carried out on data in Azure Databricks are listed below:
 The data is converted from Databricks to the data warehouse.
 Bold storage is used to load the data.
 Data is temporarily stored using bold storage.

6. Does Azure Key Vault work well as a substitute for Secret Scopes?
That is certainly doable. However, some setup is necessary. The preferred approach is this.
Instead of changing the defined secret, start creating a scoped password that Azure Key Vault
will backup if the data in secret needs to be changed.
7. How should Databricks code be handled when using TFS or Git for
collaborative projects?
TFS is not supported, to start. Your only choices are dispersed Git repository systems and Git.
Although it would be ideal to integrate Databricks with the Git directory of notebooks, it works
much like a different project clone. Making a notebook, trying to commit it to version control,
and afterwards updating it are the first steps.

8. Does Databricks have to be run on a public cloud like AWS or Azure, or


can it also run on cloud infrastructure?
This is not true. The only options you have right now are AWS and Azure. But Databricks uses
Spark, which is open-source. Although you could build your own cluster and run it in a private
cloud, you'd be giving up access to Databricks' robust features and administration.
9. How is a Databricks personal access token created?
 On the Databricks desktop, click the "user profile" icon in the top right corner.

 Choosing "User setting."

 Activate the "Access Tokens" tab.

 A "Generate New Token" button will then show up. Just click it.

10. What steps must be taken to revoke a private access token?


 On the Databricks desktop, click the "user profile" icon in the top right corner.
 Choosing "User setting."

 Activate the "Access Tokens" tab.

 To cancel a token, click the "x" button next to it.

11. What function does Kafka fulfill?


Azure Databricks connects to action hubs and data sources like Kafka when it decides to gather
or stream data.
12. What does the Azure data lake serve?
In order to manage, secure, and analyze particular management and administration, Azure data
lakes are employed in combination with other IT investments. Additionally, it allows us to
improve data applications by utilizing operating repositories and data stores.
13. Why is Azure blob cloud storage backup required?
Blob storage enables redundancy, but it might not be able to handle application failures that
could bring down the entire database. We have to continue using secondary Azure blob storage
as a result.
14. Can Spark handle streaming data processing?
Undoubtedly, Spark Streaming is an essential part of Spark. There is support for multiple
streaming processes. You can publish to a document, read from streaming, and stream a lot of
deltas.
15. Is code reuse possible in the Azure notebook?
We should import the code first from Azure notebook into our notebook so that we can reuse it.
There are two ways we can import it.
 We must first create a component for the code if it is located on a different workstation

before integrating it into the module.

 We can import and use the code right away if it is on the same workstation.

Databricks Interview Questions For Experienced


16. What is a Databricks cluster?
The settings and computing power that make up a Databricks cluster allow us to perform
statistical science, big data, and powerful analytic tasks like production ETL, workflows, deep
learning, and stream processing.

17. Is it possible to use Databricks to load data into ADLS from on-premises
sources?
Even though ADF is a fantastic tool for putting data into lakes, if the lakes are on-premises, you
will also need a "self-hosted integration runtime" to give ADF access to the data.
18. What parts of Databricks are there?
 A secure collaborative workstation for developers to code in real-time.

 Managed Groupings to increase query processing speed.

 Delta to address the issues with traditional data lake file formats and manage in-memory

data analysis.

 ML Flow to address rising production challenges and ML lifecycle.

 SQL Analytics, which creates queries to retrieve information from data lakes and display

it in dashboards.

19. What distinguishes data lakes from data warehouses?


The majority of the structured data in data warehouses has been processed and is managed
locally with in-house expertise. You cannot so easily change its structure. All types of data,
including unstructured data, such as raw and old data, are present in data lakes. They can be
easily scaled up, and the data model could be modified quickly. It uses parallel processing to
crunch the data and is retained by third-party tools, ideally in the cloud.
20. Is Databricks only available in the cloud and does not have an on-
premises option?
Yes. Databricks' foundational software, Apache Spark, was made available as an on-premises
solution, allowing internal engineers to manage both the data and the application locally. Users
who access Databricks with data on local servers will encounter network problems because it is
a cloud-native application. The on-premises choices for Databricks are also weighed against
workflow inefficiencies and inconsistent data.
21. Is Databricks owned by Microsoft?
No. Databricks is still an Apache Spark-based open-sourced product. In 2019, Microsoft
invested $250 million. Microsoft has released Azure Databricks in 2017 after integrating some
of Databricks' services into its cloud service. Both Google Cloud GCP and Amazon Cloud AWS
have similar alliances in place.
22. What type of cloud services does Databricks provide? Do you mean
SaaS, PaaS, or IaaS?
The purpose of Databricks' Software as a Service (SaaS) service is to utilize the capabilities of
Spark clusters to manage storage. Users will only need to deploy new applications after making
changes to their configurations.
[ Related Article: Introduction to Azure SaaS ]
23. What type of cloud service does Azure Databricks provide? Do you
mean SaaS, PaaS, or IaaS?
Platform as a Service (PaaS) is the category in which the Azure Databricks service falls. It
offers a platform for application development with features based on Azure and Databricks.
Utilizing the services provided by Azure Databricks, users must create and build the data life
cycle and develop applications.
24. AWS Databricks and Azure Databricks side by side.
The product of effectively integrating Azure and Databricks features is Azure Databricks.
Databricks are not just being hosted on the Azure platform. Azure Databricks is a superior
product thanks to MS characteristics like Active Directory authentication and assimilation of
many Azure functionalities. AWS Databricks merely serves as an AWS cloud server for
Databricks.
25. What type of cloud service does Azure Databricks provide? Do you
mean SaaS, PaaS, or IaaS?
Platform as a Service (PaaS) is the category in which the Azure Databricks service falls. It
offers a platform for application development with features based on Azure and Databricks.
Utilizing the services provided by Azure Databricks, users must develop the data life span and
develop applications.
26. What languages does Databricks support?
Java, R, Python, Scala, and Standard SQL. It also supports a number of language APIs,
including PySpark, Spark SQL, [Link], SparkR or SparklE, and Spark.
Most Common Azure Databricks FAQs
1. What are Databricks?
Azure provides Databricks, a cloud-based tool for processing and transforming large amounts
of data.
2. What is Azure from Microsoft?
It is a platform for cloud computing. To give users access to the services on demand, the
service provider could indeed set up a service model in Azure.
3. Describe DBU.
Databricks Unified, also known as DBU, is a framework for managing resources and
determining prices.
4. What sets Azure Databricks apart from regular Databricks?
In order to advance statistical modeling and predictive analytics, Microsoft and Databricks have
collaborated to create Azure Databricks.
5. What advantages do Azure Databricks offer?
Among the many advantages of Azure Databricks are its lower costs, higher productivity, and
enhanced security.

6. Can Databricks and Azure Notebooks coexist?


Although they can be carried out similarly, data transmission to the cluster must be manually
coded. This integration can be completed without any issues thanks to Databricks Connect.
7. What kinds of clusters are available in Azure Databricks?
There are four different cluster types in Azure Databricks, including interactive, job, low-priority,
and high-priority clusters.
8. Describe caching.
The act of temporarily storing information is referred to as caching. Your browser uses the data
from the cache rather than the server when you visit a website that you frequent. Time is saved,
and the load on the server is decreased.
9. Is it acceptable to delete the cache?
It is acceptable to clear the cache because no programme requires the information.
10. What steps must be taken to revoke a private authentication code?
Go to "user profile" and choose "User setting" to cancel the token. Click the "x" next to the token
you want to revoke by selecting the "Access Tokens" tab. Finally, click the "Revoke Token"
button on the Revoke Token window.

You might also like