Given a denormalized dataset, how would you extract the desired columns or transform it into a normalized form using Python, Spark, or SQL?
💡 Model Answer
When you have a denormalized table—say a single row contains multiple comma‑separated values or nested JSON—you can transform it into a normalized form using SQL, Spark, or Python. In SQL, you can use STRING_SPLIT or CROSS APPLY to explode comma‑separated columns, then SELECT the desired fields. In Spark, you can read the data into a DataFrame, use the explode function on an array column, or parse JSON with from_json, then select and write the result. In Python, you can read the CSV with pandas, use str.split and explode, or parse JSON with json.loads, then flatten the structure. The key steps are: 1) Identify the denormalized columns; 2) Split or parse them into separate rows or columns; 3) Apply any necessary transformations; 4) Write the normalized data back to a target table or file. This approach keeps the data consistent and queryable.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500