Tata Digital Interview Questions
All three are SQL window functions that assign a number to rows within a result set ordered by a specific column: Function Behavior with ties Gaps after...
Explain the difference between RANK(), DENSE_RANK() and ROW_NUMBER() in SQL.
All three are SQL window functions that assign a number to rows within a result set ordered by a specific column: Function Behavior with ties Gaps after ties ROW NUMBER() Always unique — arbitrary ordering among tied rows N/A (always sequential) RANK() Tied rows get the same rank Yes — gaps exist (1, 1, 3, 4…) DENSE RANK() Tied rows get the same rank No — no gaps (1, 1, 2, 3…) Sample output (two employees with salary 90000): When to use each: ROW NUMBER() : Pagination, deduplication (pick one ro
What is a CTE (Common Table Expression)? When is it better to use a CTE over subqueries?
A CTE (Common Table Expression) is a named, temporary result set defined with the WITH keyword that exists only for the duration of a single query. CTEs vs Subqueries: CTE Subquery Readability High — named and defined at the top Lower for complex, nested queries Reuse Can be referenced multiple times in the main query Must be repeated each time Recursion Recursive CTEs (WITH RECURSIVE) are possible Not supported Debugging Easier to test in isolation Harder to isolate intermediate steps Performan
How is exception handling managed in production-grade Python pipelines?
Production Python data pipelines require robust exception handling to ensure observability, graceful degradation, and recoverability: Structured try/except with specific exceptions: Key patterns: Catch specific exceptions — avoid bare except: which catches SystemExit and KeyboardInterrupt . Re raise critical errors (network, DB connection) so Airflow/Celery retry mechanisms can kick in. Dead letter queues / quarantine files : Write failed records to a separate location instead of dropping them s
How would you persist intermediate data in a PySpark pipeline? Compare cache() vs persist().
In PySpark, caching and persisting store a DataFrame in memory (and optionally disk) to avoid recomputing it when it is used multiple times in the DAG. cache() is a shorthand for persist(StorageLevel.MEMORY AND DISK) : persist(StorageLevel) gives explicit control over storage: When to use: Cache when a DataFrame is used in 2+ downstream actions (avoids full recomputation each time). Use DISK ONLY for very large DataFrames that don't fit in executor memory. Always call .unpersist() when done to f
Explain the role of DAG (Directed Acyclic Graph) in Spark job execution.
In Apache Spark, a DAG (Directed Acyclic Graph) represents the logical execution plan of a job — a graph of transformations where each node is an RDD/DataFrame operation and edges represent data dependencies. How Spark builds and uses the DAG: 1. Lazy evaluation : When you call transformations ( filter , map , join ), Spark does not execute them immediately. It builds a DAG representing what needs to be done . 2. Action triggers execution : When an action ( count , collect , save ) is called, th
How does Spark handle data shuffles? What are broadcast joins and when would you use them?
Shuffles occur during wide transformations ( groupBy , join , distinct , repartition ) and involve redistributing data across partitions over the network — the most expensive Spark operation. How shuffles work: 1. Each executor writes shuffle output (map output files) to local disk, partitioned by the target key's hash. 2. In the reduce phase, each executor reads its assigned partitions from all other executors over the network. 3. The number of reduce partitions is controlled by spark.sql.shuff
Your ingestion script fails intermittently on weekends but runs fine on weekdays. What steps do you take to debug this issue?
Intermittent weekend failures point to a time dependent or environment dependent root cause . A systematic debugging approach: 1. Gather evidence from logs: Review pipeline logs, Airflow task logs, and cloud logging (Cloud Logging / CloudWatch) for error messages and stack traces. Compare a successful weekday run vs a failed weekend run — look for differences in execution time, error message, row counts. 2. Identify potential weekend specific causes: Data volume differences : Weekend data might
What are the methods available for offline data center migration to Google Cloud Platform (GCP)?
Offline migration moves data to GCP without relying solely on internet connectivity — critical for large datasets where online transfer would take days or weeks: 1. Transfer Appliances (Google Transfer Appliance): Google ships a physical high capacity appliance (100 TB or 480 TB) to your data center. You copy data to it locally at network speeds (not internet speeds), then ship it back to Google. Google uploads the data to GCS from the appliance at their data center. Best for multi TB to PB scal