You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2024/02/01 02:24:11 UTC
(superset) 01/01: fix: column values with NaN
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch fix-athena-nan
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 7b8f11718ffe9eccfebfcb638419c4d798b48a66
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Jan 31 21:18:01 2024 -0500
fix: column values with NaN
---
superset/models/helpers.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index fa2c9b8102..9322e8c46d 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -1340,7 +1340,10 @@ class ExploreMixin: # pylint: disable=too-many-public-methods
return and_(*l)
def values_for_column(
- self, column_name: str, limit: int = 10000, denormalize_column: bool = False
+ self,
+ column_name: str,
+ limit: int = 10000,
+ denormalize_column: bool = False,
) -> list[Any]:
# denormalize column name before querying for values
# unless disabled in the dataset configuration
@@ -1378,6 +1381,8 @@ class ExploreMixin: # pylint: disable=too-many-public-methods
sql = self.mutate_query_from_config(sql)
df = pd.read_sql_query(sql=sql, con=engine)
+ # replace NaN with None to ensure it can be serialized to JSON
+ df = df.replace({np.nan: None})
return df["column_values"].to_list()
def get_timestamp_expression(