Cognizant Interview Questions
Both repartition() and coalesce() change the number of partitions in a PySpark DataFrame, but they work very differently: repartition(n) Performs a full...
Difference between repartition and coalesce in PySpark.
Both repartition() and coalesce() change the number of partitions in a PySpark DataFrame, but they work very differently: repartition(n) Performs a full shuffle — redistributes all data evenly across n partitions Can both increase and decrease the number of partitions Creates evenly balanced partitions (important for preventing data skew) More expensive due to the shuffle operation Optional: repartition(n, col) — hash partitions by a column value coalesce(n) Performs a partial shuffle (or no shu
How do you persist and cache data in PySpark?
PySpark's persist and cache mechanisms store intermediate DataFrames in memory (or disk) to avoid recomputing them from scratch when they are used multiple times. cache() — shorthand for default persistence persist(storageLevel) — explicit storage level control Storage level guide: Level Memory Use CPU Cost Disk Fallback MEMORY ONLY High Low No (recompute) MEMORY AND DISK Medium Low Yes MEMORY ONLY SER Lower Higher No DISK ONLY Minimal Higher Always unpersist() — release cached data When to cach
How do Azure Logic Apps automate SQL workflows?
Azure Logic Apps is a serverless workflow automation service that connects Azure services and external systems using a visual designer. It can automate SQL related workflows without writing server code. Common SQL automation scenarios: 1. Scheduled SQL execution (e.g., daily report generation) Trigger: Recurrence trigger (every day at 8AM) Action: SQL Server — Execute stored procedure or Execute query Action: Send email (Office 365) with query results 2. File arrival triggered SQL load Trigger:
Difference between ADLS Gen1 and Gen2.
ADLS Gen1 (Azure Data Lake Store) and ADLS Gen2 (built on Azure Blob Storage) are both Azure data lake offerings, but Gen2 represents a significant architectural upgrade. Key differences: Feature ADLS Gen1 ADLS Gen2 Underlying storage Dedicated service Azure Blob Storage with HNS Hierarchical Namespace Yes Yes (must be enabled) Blob Storage API Not supported Fully supported Protocol support WebHDFS, REST ABFS (Azure Blob File System), REST, NFS 3.0 Access control POSIX ACLs only POSIX ACLs + Azu
Write a SQL query to find gaps in a sequence.
Finding gaps in a sequence (e.g., missing IDs, order numbers, or dates) is a classic SQL problem solved using window functions or self joins. Setup: Approach 1: Using LAG() window function (find start of each gap) Result: Approach 2: Generate expected sequence and find missing values Approach 3: Self join approach (for databases without window functions) Date gap example:
High availability and disaster recovery for Azure SQL.
Azure SQL Database has built in High Availability (HA) and multiple Disaster Recovery (DR) options. Built in High Availability: 1. General Purpose / Standard tier Uses remote storage (Azure Premium Storage) with compute/storage separation 3 replicas of data files; compute restarts on a new node if failure occurs 99.99% SLA , ~30 second failover time 2. Business Critical / Premium tier Always On Availability Group : 3 4 synchronous replicas (primary + readable secondaries) Failover in seconds (sy
Explain Azure DevOps pipelines.
Azure DevOps Pipelines is a CI/CD (Continuous Integration / Continuous Deployment) service that automates the build, test, and deployment of code. In data engineering, it's used to deploy ADF pipelines, Databricks jobs, dbt models, and infrastructure. Core concepts: 1. YAML Pipelines (preferred) Pipeline defined as code in azure pipelines.yml stored in the repo Version controlled alongside application code Supports multi stage pipelines 2. Stages, Jobs, and Steps hierarchy: 3. Triggers CI trigge
How do you implement data masking in ADF?
Data masking in ADF hides or obfuscates sensitive data (PII, PHI, financial data) during data movement or transformation, ensuring non privileged consumers cannot see raw values. 1. Dynamic Data Masking in Azure SQL (source level) Configure masking rules directly on the source Azure SQL Database Non privileged users see masked values; privileged users see actual data ADF pipelines copying from Azure SQL will receive masked data if the service principal lacks UNMASK permission 2. Masking in ADF M