dennisimoo opened a new pull request, #44189:
URL: https://github.com/apache/superset/pull/44189
### SUMMARY
Avoid collisions between generated duplicate-column suffixes and names
already supplied by the database cursor.
For columns `a, a, a__1`, `dedup()` currently returns `a, a__1, a__1`.
Constructing `SupersetResultSet` then raises `ValueError: field 'a__1' occurs
more than once` while building the NumPy dtype.
Reserve the original names and skip occupied suffixes in the existing
counter loop. The output becomes `a, a__2, a__1`, preserving the explicitly
named column. Existing non-colliding naming, column order, case-sensitivity
options, and custom suffixes are retained. This adds an O(n) set of reserved
names and does not change result values.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Backend-only change. A result row `(1, 2, 3)` with cursor column names `a,
a, a__1` previously raised the error above. It now produces `{"a": 1, "a__2":
2, "a__1": 3}`.
### TESTING INSTRUCTIONS
- Regression cases failed before the fix, including the actual
`SupersetResultSet` constructor failure.
- `pytest -q tests/unit_tests/result_set_test.py`: 27 passed (Python 3.11).
- Tests cover occupied suffixes before and after duplicates, several
reserved suffixes, case-sensitive and case-insensitive comparisons, and a
custom uppercase suffix.
To reproduce, run the new `test_result_set_with_colliding_column_suffix`
test or execute `SELECT 1 AS a, 2 AS a, 3 AS a__1` through SQL Lab on an engine
permitting duplicate output labels.
### ADDITIONAL INFORMATION
- [ ] Has associated issue
- [ ] Required feature flags
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
AI disclosure: This patch, tests, and description were prepared and checked
by OpenAI Codex at the account owner's explicit request. No independent human
review is claimed.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]