Error Handling and Debugging
Error Handling and Debugging
When a query fails:
- Syntax errors: Check for dialect-specific syntax (e.g.,
ILIKEnot available in BigQuery,SAFE_DIVIDEonly in BigQuery) - Column not found: Verify column names against schema -- check for typos, case sensitivity (PostgreSQL is case-sensitive for quoted identifiers)
- Type mismatches: Cast explicitly when comparing different types (
CAST(col AS DATE),col::DATE) - Division by zero: Use
NULLIF(denominator, 0)or dialect-specific safe division - Ambiguous columns: Always qualify column names with table alias in JOINs
- Group by errors: All non-aggregated columns must be in GROUP BY (except in BigQuery which allows grouping by alias)