Persistent Interview Questions
A broadcast join in PySpark is a join optimization where the smaller DataFrame is broadcast (copied in full) to every executor node, eliminating the nee...
Explain broadcast join in PySpark.
A broadcast join in PySpark is a join optimization where the smaller DataFrame is broadcast (copied in full) to every executor node, eliminating the need to shuffle the larger DataFrame across the network. How it works: Spark serializes the small DataFrame and sends a copy to every executor Each executor performs the join locally with its partition of the large DataFrame No data movement for the large DataFrame → massive performance improvement When to use: One table is significantly smaller tha
How do you create a rank column using Window functions?
Window functions in PySpark allow you to compute rankings over a partition of rows without collapsing the DataFrame. There are three ranking functions, each behaving differently with ties. Setup: 1. RANK() — Gaps after ties 2. DENSE RANK() — No gaps after ties 3. ROW NUMBER() — Unique sequential, ties broken arbitrarily Common use case — Keep top N records per group: Equivalent SQL:
What is the binary copy method in ADF?
Binary copy in Azure Data Factory (ADF) is a Copy Activity mode that transfers files as is without any parsing, deserialization, or schema translation. The data is treated as a raw byte stream from source to sink. Key characteristics: No data transformation or format conversion Preserves the exact original file (including metadata like timestamps, permissions where supported) Fastest copy mode since ADF doesn't need to parse file content Supports any file format (CSV, Parquet, JSON, images, ZIP,
How do you monitor and optimize Azure Synapse performance?
Azure Synapse Analytics performance monitoring and optimization spans both the Dedicated SQL Pool and Spark Pool layers. Monitoring Tools: 1. Synapse Studio Monitor Hub Pipeline runs, SQL requests, Spark applications, data flow activities View active queries, execution time, resource utilization in real time 2. Dynamic Management Views (DMVs) for SQL Pool 3. Azure Monitor + Log Analytics — stream Synapse diagnostic logs for historical analysis Optimization Strategies: Distribution: Use HASH dist
Write Python code to identify duplicates and count them.
Here are multiple approaches to identify and count duplicates in Python: 1. Using collections.Counter on a list 2. Identifying duplicate rows in a list of dictionaries 3. Using pandas for tabular data (most common in data engineering) 4. Using set to find unique duplicates efficiently
Key features of Azure DevOps.
Azure DevOps is Microsoft's integrated platform for end to end software and data pipeline delivery. It consists of five core services: 1. Azure Boards Agile project management: Kanban boards, backlogs, sprints, work items Track bugs, user stories, tasks, epics Integration with GitHub commits and pull requests 2. Azure Repos Hosted Git repositories (or TFVC for legacy) Branch policies: require PR reviews, status checks, linked work items Used to version control ADF pipelines, Databricks notebooks
How do you handle schema drift in ADF?
Schema drift occurs when source data structure changes unexpectedly — new columns appear, columns are removed, or data types change. ADF's Mapping Data Flows provides built in schema drift handling. 1. Enable Allow Schema Drift on Source In the source transformation of a Mapping Data Flow, enable Allow Schema Drift ADF will accept any incoming columns without failing, even those not defined in the dataset schema projection 2. Enable Auto Mapping on Sink In the sink transformation, enable Auto Ma
Explain denormalization and its use cases.
Denormalization is the process of intentionally introducing redundancy into a database schema by combining tables (merging normalized tables) or duplicating data, trading storage efficiency for query performance. Contrast with Normalization: Normalized (3NF): Data stored in separate related tables, minimal redundancy, complex JOINs needed to query Denormalized : Data combined into fewer, wider tables, some redundancy, faster reads with fewer JOINs Techniques: 1. Pre joining tables — merge dimens