mirror of
https://github.com/apache/superset.git
synced 2026-05-11 19:05:24 +00:00
fix(mcp): prevent encoding errors and fix tool bugs on MCP client transports (#38786)
(cherry picked from commit ed3c5280a9)
This commit is contained in:
committed by
Michael S. Molina
parent
de42d4a986
commit
ac8d6b0c53
@@ -839,13 +839,22 @@ class SQLExecutor:
|
||||
or app.config.get("CACHE_DEFAULT_TIMEOUT", 300)
|
||||
)
|
||||
|
||||
# Serialize statement results for caching
|
||||
# Serialize statement results for caching.
|
||||
# Convert DataFrames to list-of-dicts so the cache backend
|
||||
# does not need to pickle pandas objects (which can fail to
|
||||
# deserialize correctly with some backends or pandas versions).
|
||||
import pandas as pd
|
||||
|
||||
cached_data = {
|
||||
"statements": [
|
||||
{
|
||||
"original_sql": stmt.original_sql,
|
||||
"executed_sql": stmt.executed_sql,
|
||||
"data": stmt.data,
|
||||
"data": (
|
||||
stmt.data.to_dict(orient="records")
|
||||
if isinstance(stmt.data, pd.DataFrame)
|
||||
else stmt.data
|
||||
),
|
||||
"row_count": stmt.row_count,
|
||||
"execution_time_ms": stmt.execution_time_ms,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user