mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
fix(mcp): prevent encoding errors and fix tool bugs on MCP client transports (#38786)
This commit is contained in:
@@ -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