villebro commented on code in PR #23476:
URL: https://github.com/apache/superset/pull/23476#discussion_r1147222862


##########
superset/common/query_context_processor.py:
##########
@@ -447,7 +448,7 @@ def processing_time_offsets(  # pylint: 
disable=too-many-locals,too-many-stateme
         rv_df = pd.concat(rv_dfs, axis=1, copy=False) if time_offsets else df
         return CachedTimeOffset(df=rv_df, queries=queries, 
cache_keys=cache_keys)
 
-    def get_data(self, df: pd.DataFrame) -> Union[str, List[Dict[str, Any]]]:
+    def get_data(self, df: pd.DataFrame, coltypes:[]) -> Union[str, 
List[Dict[str, Any]]]:

Review Comment:
   same here



##########
superset/common/query_context.py:
##########
@@ -88,8 +88,9 @@ def __init__(
     def get_data(
         self,
         df: pd.DataFrame,
+        coltypes:[] = None

Review Comment:
   nit, I think the linter would have complained, and I'd rather we be more 
explicit (maybe even make it required):
   ```suggestion
           coltypes: Optional[List[str]] = None
   ```



##########
superset/common/query_context_processor.py:
##########
@@ -457,11 +458,17 @@ def get_data(self, df: pd.DataFrame) -> Union[str, 
List[Dict[str, Any]]]:
 
             result = None
             if self._query_context.result_format == ChartDataResultFormat.CSV:
-                result = csv.df_to_escaped_csv(
-                    df, index=include_index, **config["CSV_EXPORT"]
-                )
-            elif self._query_context.result_format == 
ChartDataResultFormat.XLSX:
-                result = excel.df_to_excel(df, **config["EXCEL_EXPORT"])
+                ndf = df.copy()
+                columns = list(df)
+                i = 0
+                for c in columns:
+                    coltype = None
+                    if i<len(coltypes):
+                        coltype = coltypes[i]
+                        if coltype == GenericDataType.NUMERIC:
+                            ndf[c] = pd.to_numeric(df[c], errors='ignore')
+                    i+=1
+                result = excel.df_to_excel(ndf, **config["EXCEL_EXPORT"])

Review Comment:
   I may be missing something obvious here, but why are we no longer checking 
for `self._query_context.result_format == ChartDataResultFormat.XLSX`?



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

Reply via email to