codeant-ai-for-open-source[bot] commented on code in PR #42040:
URL: https://github.com/apache/superset/pull/42040#discussion_r3579466293
##########
tests/unit_tests/models/helpers_test.py:
##########
@@ -3672,3 +3672,53 @@ def
test_temporal_non_numeric_string_filter_is_not_coerced() -> None:
)
assert value == "2025-12-20"
+
+
+def test_get_sqla_query_calculated_column_inlined_in_raw_records(
+ database: Database,
+) -> None:
+ """Regression test for #34784: a calculated column selected as an adhoc
+ column in a raw-records query (no groupby/metrics) must have its stored
+ SQL expression inlined, not emitted as a bare column reference."""
+ from superset.connectors.sqla.models import SqlaTable, TableColumn
+
+ table = SqlaTable(
+ database=database,
+ schema=None,
+ table_name="t",
+ columns=[
+ TableColumn(column_name="a", type="INTEGER"),
+ TableColumn(column_name="b", type="TEXT"),
+ TableColumn(
+ column_name="name_test",
+ type="TEXT",
+ expression="CASE WHEN a > 0 THEN 'positive' ELSE
'non-positive' END",
+ ),
+ ],
+ )
+
+ # No metrics/groupby => the ``elif columns:`` branch runs.
+ adhoc_col: AdhocColumn = {
+ "sqlExpression": "name_test",
+ "label": "name_test",
+ "isColumnReference": True,
+ }
+ sqlaq = table.get_sqla_query(
+ columns=[adhoc_col],
+ is_timeseries=False,
+ row_limit=10,
+ )
+
+ with database.get_sqla_engine() as engine:
+ sql = str(
Review Comment:
**Suggestion:** Add explicit type annotations to newly introduced local
variables that hold key objects/results so they are statically checked under
the type-hint rule. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The added test introduces clearly annotatable local variables (`table`,
`sqlaq`, and `sql`) without type hints. This matches the Python type-hint rule
for newly added code, so the suggestion is a real violation.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=cf9f092c7ec04ed28b42dac8e758675a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=cf9f092c7ec04ed28b42dac8e758675a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/models/helpers_test.py
**Line:** 3685:3713
**Comment:**
*Custom Rule: Add explicit type annotations to newly introduced local
variables that hold key objects/results so they are statically checked under
the type-hint rule.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42040&comment_hash=4d25b9cd3fc51ef6f2faf8b6278d96b966aeb5dadd157f04180ceec11fc784ad&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42040&comment_hash=4d25b9cd3fc51ef6f2faf8b6278d96b966aeb5dadd157f04180ceec11fc784ad&reaction=dislike'>๐</a>
--
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]