nada-attia opened a new pull request, #18147:
URL: https://github.com/apache/hudi/pull/18147

   ### Describe the issue this Pull Request addresses
   
   When Spark SQL queries contain unresolved columns or tables (e.g., typos, 
missing table definitions), users receive a cryptic error message like "Invalid 
call to dataType on unresolved object" which provides no actionable 
information. This PR improves error handling to catch `UnresolvedException` and 
provide user-friendly error messages that help users identify and fix the issue.
   
   ### Summary and Changelog
   
   **Summary:** Improved error handling in Hudi's Spark SQL analysis phase to 
provide clear, actionable error messages when queries contain unresolved 
references.
   
   **Changelog:**
   - Modified `ProducesHudiMetaFields.unapply` in `HoodieAnalysis.scala` to 
catch `UnresolvedException`
   - Added `collectUnresolvedReferences` helper method to identify specific 
unresolved column/table names
   - Throws `AnalysisException` with helpful error message including:
     - List of unresolved references found in the query
     - Suggestions to check for typos, missing table definitions, incorrect 
schema references
     - Original error message for debugging
   
   ### Impact
   
   - **User-facing change:** Users will now see clear error messages like:
     ```
     Failed to resolve query. The query contains unresolved columns or tables. 
Unresolved references: [nonexistent_column].
     Please check for: (1) typos in column or table names, (2) missing table 
definitions, 
     (3) incorrect database/schema references, (4) columns that don't exist in 
the source tables.
     ```
   - **No API changes**
   - **No performance impact**
   
   ### Risk Level
   
   **Low** - This change only affects error handling in the analysis phase. It 
catches a specific exception type (`UnresolvedException`) and re-throws it as a 
more informative `AnalysisException`. Normal query execution paths are 
unaffected.
   
   ### Documentation Update
   
   None - This is an internal improvement to error messages that doesn't 
require documentation updates.
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to