Challenge: Error Handling
Swipe um das Menü anzuzeigen
Refactor the provided query using the sales_data table to ensure it is robust, error-proof, and handles inconsistent data gracefully.
- Implement fault-tolerant calculations to prevent runtime errors:
- Use
SAFE_DIVIDEfor division operations to prevent division by zero; - Use
COALESCEon thesales_pricecolumn to replaceNULLvalues with0; - Ensure your query returns safe calculated columns without failing.
- Use
- Navigate arrays safely to avoid out-of-bounds errors:
- Use
SAFE_OFFSETto extract elements from arrays; - Ensure that missing indices return
NULLinstead of causing the query to crash.
- Use
- Ensure structural integrity and add validation flags:
- Handle
LEFT JOINnulls by replacing missing joined values with"Unknown"; - Add a new column to flag potential data quality issues (e.g., missing data, negative price, invalid quantity);
- Ensure your final query keeps data issues visible for debugging rather than silently filtering them out.
- Handle
Note
Robust error handling relies on three pillars: Safe Division, Safe Array Access, and Null Handling. A query is only as strong as its ability to handle the data you did not expect.
War alles klar?
Danke für Ihr Feedback!
Abschnitt 4. Kapitel 4
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Abschnitt 4. Kapitel 4