codeant-ai-for-open-source[bot] commented on code in PR #41870:
URL: https://github.com/apache/superset/pull/41870#discussion_r3540762636
##########
tests/integration_tests/db_engine_specs/base_engine_spec_tests.py:
##########
@@ -202,6 +204,51 @@ def
test_calculated_column_in_order_by_base_engine_spec(self):
in sql
)
+ @mock.patch("superset.models.core.Database.db_engine_spec", BaseEngineSpec)
+ @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
+ def test_jinja_calculated_column_in_order_by(self) -> None:
+ """
+ A calculated column referenced by a SIMPLE adhoc metric in `orderby`
+ should have its Jinja template rendered, the same way it is for
+ SELECT/WHERE/GROUP BY.
+ """
+ table = self.get_table(name="birth_names")
+ TableColumn(
+ column_name="gender_cc_jinja",
+ type="VARCHAR(255)",
+ table=table,
+ expression="""
+ case
+ when gender='boy' then {{ "'male'" }}
+ else {{ "'female'" }}
+ end
+ """,
+ )
+
+ table.database.sqlalchemy_uri = "sqlite://"
+ query_obj = {
+ "groupby": ["gender_cc_jinja"],
+ "is_timeseries": False,
+ "filter": [],
+ "orderby": [
+ [
+ {
+ "expressionType": "SIMPLE",
+ "column": {"column_name": "gender_cc_jinja"},
+ "aggregate": "MAX",
+ "label": "max_gender_cc_jinja",
+ },
+ True,
+ ]
+ ],
+ }
+ sql = table.get_query_str(cast(QueryObjectDict, query_obj))
Review Comment:
**Suggestion:** Add an explicit type annotation to the newly introduced
query payload variable instead of relying on a cast at call time. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new variable `query_obj` is a Python dictionary literal introduced
without a type annotation, even though its type is known and it is later cast
only at the call site. This matches the rule requiring type hints on relevant
variables that can be annotated.
</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=ffb68b37b5d648bcb146afb265c3cf8c&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=ffb68b37b5d648bcb146afb265c3cf8c&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/integration_tests/db_engine_specs/base_engine_spec_tests.py
**Line:** 229:245
**Comment:**
*Custom Rule: Add an explicit type annotation to the newly introduced
query payload variable instead of relying on a cast at call time.
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%2F41870&comment_hash=96934cd5894e4cca3b3d2607f379e38f75711f09338b170d1ea7cbb095521e8a&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41870&comment_hash=96934cd5894e4cca3b3d2607f379e38f75711f09338b170d1ea7cbb095521e8a&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]