You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/08/26 02:13:58 UTC
[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20465: fix: Custom sql issue in table viz with raw records
zhaoyongjie commented on code in PR #20465:
URL: https://github.com/apache/superset/pull/20465#discussion_r955582167
##########
superset/connectors/sqla/models.py:
##########
@@ -1379,15 +1379,23 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
select_exprs.append(outer)
elif columns:
for selected in columns:
- selected = validate_adhoc_subquery(
- selected,
+ selected_query = (
+ selected["sqlExpression"]
+ if "sqlExpression" in selected
+ else selected
+ )
+ label_expected = selected["label"] if "label" in selected else selected
+ selected_query = validate_adhoc_subquery(
+ selected_query,
self.database_id,
self.schema,
)
select_exprs.append(
- columns_by_name[selected].get_sqla_col()
- if selected in columns_by_name
- else self.make_sqla_column_compatible(literal_column(selected))
+ columns_by_name[selected_query].get_sqla_col()
+ if selected_query in columns_by_name
+ else self.make_sqla_column_compatible(
+ literal_column(selected_query), label_expected
+ )
)
Review Comment:
There is a method for converting AdHoc Column to ColumnClause, for instance:
```python
if is_adhoc_column(selected):
select_exprs.append(self.adhoc_column_to_sqla(selected))
continue
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org