fix(SQL Lab): handle columns without names#38986
Conversation
Code Review Agent Run #fc8209Actionable Suggestions - 0Additional Suggestions - 10
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SQL Server returns an empty-string column name in cursor.description for any un-aliased expression (e.g. SELECT COUNT(*), SELECT DATEPART(...)). An empty field name is illegal in NumPy structured arrays and PyArrow tables, so SupersetResultSet raised "ValueError: no field of name", surfacing as a GENERIC_DB_ENGINE_ERROR in SQL Lab and in the adhoc column type-probe path. Fix: replace empty column names with synthetic names (_col_0, _col_1, ...) during cursor.description parsing in SupersetResultSet.__init__. This covers all code paths that use SupersetResultSet – SQL Lab, Database.load_into_dataframe(), SQLExecutor, and get_columns_description (adhoc column type probing) – in one place. Fixes apache#23848
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #38986 +/- ##
==========================================
- Coverage 64.41% 64.41% -0.01%
==========================================
Files 2536 2536
Lines 131155 131172 +17
Branches 30450 30453 +3
==========================================
+ Hits 84485 84494 +9
- Misses 45207 45214 +7
- Partials 1463 1464 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Review Agent Run #f92481Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
There was a problem hiding this comment.
Pull request overview
Fixes a SQL Lab result set bug (notably impacting Microsoft SQL Server) where unnamed columns in cursor.description could cause failures when building NumPy/PyArrow-backed result tables.
Changes:
- Substitute synthetic column names (
_col_<index>) whencursor.descriptionprovides an empty column name. - Add unit tests ensuring empty (and multiple empty) column names are replaced and remain usable in Pandas conversion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
superset/result_set.py |
Generates synthetic names for empty column names before creating NumPy/PyArrow tables. |
tests/unit_tests/result_set_test.py |
Adds regression tests covering single and multiple empty column names. |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@michael-s-molina I completed that suggestion from Copilot and updated my "AFTER" screenshot to reflect that new behavior |
Code Review Agent Run #5f4c7eActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Alternatively, if the longer fix resulting from the reviewer feedback is too clunky or introduces performance concerns, a compromise would be to make the replacement names longer & odder to lessen the chance of collisions. E.g., instead of |
The current approach is safer and the limited number of columns should not cause performance problems. |
|
Thanks for the careful reviews @michael-s-molina ! |
(cherry picked from commit 12eb40d)
User description
SUMMARY
Fix #23848, a three-year-old bug affecting Microsoft SQL Server.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
BEFORE - 6.0.0
AFTER
Note that it avoids the collision with my first column explicitly named
_col_1:TESTING INSTRUCTIONS
Run a query like
SELECT COUNT(*) FROM my_tableon a DB that returns(No column name)and see that it no longer errors.ADDITIONAL INFORMATION