etr2460 commented on a change in pull request #13434:
URL: https://github.com/apache/superset/pull/13434#discussion_r595413496



##########
File path: superset/common/query_context.py
##########
@@ -129,7 +129,7 @@ def get_query_result(self, query_object: QueryObject) -> 
Dict[str, Any]:
             if self.enforce_numerical_metrics:
                 self.df_metrics_to_num(df, query_object)
 
-            df.replace([np.inf, -np.inf], np.nan)
+            df.replace([np.inf, -np.inf], np.nan, inplace=True)

Review comment:
       woah, did this not work before?

##########
File path: superset/connectors/sqla/models.py
##########
@@ -67,14 +68,16 @@
 from superset.models.helpers import AuditMixinNullable, QueryResult
 from superset.result_set import SupersetResultSet
 from superset.sql_parse import ParsedQuery
-from superset.typing import Metric, QueryObjectDict
+from superset.typing import AdhocMetric, Metric, OrderBy, QueryObjectDict
 from superset.utils import core as utils
 from superset.utils.core import GenericDataType
 
 config = app.config
 metadata = Model.metadata  # pylint: disable=no-member
 logger = logging.getLogger(__name__)
 
+VIRTUAL_TABLE_ALIAS = "expr_qry"

Review comment:
       while you're pulling this out into a constant, maybe we should make this 
table alias more clear? At least `expression_query`, but maybe it should really 
be `chart_query` or something like that?

##########
File path: superset/connectors/sqla/models.py
##########
@@ -1326,27 +1360,33 @@ def query(self, query_obj: QueryObjectDict) -> 
QueryResult:
         errors = None
         error_message = None
 
-        def mutator(df: pd.DataFrame) -> None:
+        def assign_column_label(df: pd.DataFrame) -> None:

Review comment:
       looks like this return type is wrong, it should at least be an 
`Optional[pd.DataFrame]`

##########
File path: superset/connectors/sqla/models.py
##########
@@ -1326,27 +1360,33 @@ def query(self, query_obj: QueryObjectDict) -> 
QueryResult:
         errors = None
         error_message = None
 
-        def mutator(df: pd.DataFrame) -> None:
+        def assign_column_label(df: pd.DataFrame) -> None:
             """
             Some engines change the case or generate bespoke column names, 
either by
             default or due to lack of support for aliasing. This function 
ensures that
             the column names in the DataFrame correspond to what is expected by
             the viz components.
 
-            :param df: Original DataFrame returned by the engine
-            """
+            Sometimes a query may also contain only order by columns that are 
not used
+            as metrics or groupby columns, but need to present in the SQL 
`select`,
+            filtering by `labels_expected` make sure we only return columns 
users want.
 
+            :param df: Rriginal DataFrame returned by the engine

Review comment:
       sp nit: `Original`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to