rusackas opened a new pull request, #41961:
URL: https://github.com/apache/superset/pull/41961
### SUMMARY
Test-only regression coverage for #30637 ("When creating a metric, CUSTOM
SQL does not use quotation marks even though the column requires it").
The issue reports that a metric referencing a column whose name requires
identifier quoting (e.g. it contains a space, as in `Amount HT`) can be emitted
without quotes, producing invalid SQL for dialects that require quoting. The
most recent report notes it was reproducing through 5.0.0 but appears resolved
by 6.1.0.
This PR adds a focused unit test that pins the behavior of the backend
metric compilation path named in the issue: `adhoc_metric_to_sqla` ->
`TableColumn.get_sqla_col` -> SQLAlchemy `column()`. It builds a SIMPLE adhoc
metric over a column named `Amount HT` and asserts the compiled SQL quotes the
identifier rather than emitting it bare.
The test **passes on `master`**, documenting that the SIMPLE metric
compilation path correctly quotes columns requiring quoting. It is a green
guard that will fail if that quoting ever regresses. (Note: free-form Custom
SQL expressions are rendered verbatim via `literal_column`/`sanitize_clause` by
design — quoting there is the author's responsibility — so this test targets
the compilation path a fix would actually harden.)
### How to interpret CI
- **Green (expected):** master already quotes columns requiring quoting in
the SIMPLE metric path; the test locks that in as a regression guard.
- **Red:** would indicate the metric compilation path stopped quoting
identifiers that need it — a real regression of #30637.
### TESTING INSTRUCTIONS
```bash
python -m pytest
tests/unit_tests/models/helpers_test.py::test_simple_metric_quotes_column_requiring_quoting
-v
```
### ADDITIONAL INFORMATION
- [ ] Has associated issue: Closes #30637
- [x] Test-only change; no runtime code modified.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]