bito-code-review[bot] commented on PR #42040:
URL: https://github.com/apache/superset/pull/42040#issuecomment-4969824901
<!-- Bito Reply -->
The suggestion to add explicit type annotations to the local variables
`table`, `sqlaq`, and `sql` in the newly added test is correct and aligns with
the project's standards for new code. Below is the updated code snippet with
the necessary type annotations applied:
```python
table: SqlaTable = 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: SqlaQuery = table.get_sqla_query(
columns=[adhoc_col],
is_timeseries=False,
row_limit=10,
)
with database.get_sqla_engine() as engine:
sql: str = str(
sqlaq.sqla_query.compile(
dialect=engine.dialect,
compile_kwargs={"literal_binds": True},
)
)
```
I have checked the PR comments, and there are no other pending review
comments to address. Would you like me to perform any further actions?
**tests/unit_tests/models/helpers_test.py**
```
table: SqlaTable = 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: SqlaQuery = table.get_sqla_query(
columns=[adhoc_col],
is_timeseries=False,
row_limit=10,
)
with database.get_sqla_engine() as engine:
sql: str = str(
sqlaq.sqla_query.compile(
dialect=engine.dialect,
compile_kwargs={"literal_binds": True},
)
)
```
--
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]