Skip to content

Commit

Permalink
fix: % replace in values_for_column (#28271)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida authored and michael-s-molina committed May 1, 2024
1 parent 453f747 commit cb18202
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions superset/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ def modified(self) -> Markup:


class QueryResult: # pylint: disable=too-few-public-methods

"""Object returned by the query interface"""

def __init__( # pylint: disable=too-many-arguments
Expand Down Expand Up @@ -1377,10 +1376,14 @@ def values_for_column(
qry = qry.where(self.get_fetch_values_predicate(template_processor=tp))

with self.database.get_sqla_engine_with_context() as engine:
sql = qry.compile(engine, compile_kwargs={"literal_binds": True})
sql = str(qry.compile(engine, compile_kwargs={"literal_binds": True}))
sql = self._apply_cte(sql, cte)
sql = self.mutate_query_from_config(sql)

# pylint: disable=protected-access
if engine.dialect.identifier_preparer._double_percents:
sql = sql.replace("%%", "%")

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})
Expand Down

0 comments on commit cb18202

Please sign in to comment.