rusackas commented on code in PR #27905: URL: https://github.com/apache/superset/pull/27905#discussion_r1554505022
########## superset/result_set.py: ########## @@ -69,17 +69,24 @@ def stringify_values(array: NDArray[Any]) -> NDArray[Any]: with np.nditer(result, flags=["refs_ok"], op_flags=[["readwrite"]]) as it: for obj in it: - if na_obj := pd.isna(obj): - # pandas <NA> type cannot be converted to string - obj[na_obj] = None + item = obj.item() # Extract the scalar value for manipulation + if pd.isna(item): # Handle missing values by setting them to None + obj[...] = None else: - try: - # for simple string conversions - # this handles odd character types better - obj[...] = obj.astype(str) - except ValueError: - obj[...] = stringify(obj) - + if isinstance(item, str): # Apply ASCII check only to strings + try: + if item.encode("ascii", "ignore").decode() == item: + obj[...] = item # It's fully ASCII, leave as is + else: + obj[...] = item # It's a non-ASCII string, leave as is + except UnicodeEncodeError: + obj[...] = item # Handle potential encoding issues Review Comment: You're quite right... that was a mid-stream revision. I pushed another update that seems closer to my goal, but it's not working as expected, it seems. I'm dabbling in things I'm not an expert at, so I've just converted this to a draft and will fiddle with it when I have spare time unless someone wants to steer me in a better direction :P -- 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-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org