Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: Handling Null Values in SQL Execution Results (#10332)

Womsxdccb1c269e8d8
diff --git a/agent/tools/exesql.py b/agent/tools/exesql.py
index 464f060959..2e1cc24bfd 100644
--- a/agent/tools/exesql.py
+++ b/agent/tools/exesql.py
@@ -162,6 +162,8 @@ class ExeSQL(ToolBase, ABC):
if pd.api.types.is_datetime64_any_dtype(df[col]):
df[col] = df[col].dt.strftime("%Y-%m-%d")
+ df = df.where(pd.notnull(df), None)
+
sql_res.append(convert_decimals(df.to_dict(orient="records")))
formalized_content.append(df.to_markdown(index=False, floatfmt=".6f"))
@@ -197,6 +199,8 @@ class ExeSQL(ToolBase, ABC):
if pd.api.types.is_datetime64_any_dtype(single_res[col]):
single_res[col] = single_res[col].dt.strftime('%Y-%m-%d')
+ single_res = single_res.where(pd.notnull(single_res), None)
+
sql_res.append(convert_decimals(single_res.to_dict(orient='records')))
formalized_content.append(single_res.to_markdown(index=False, floatfmt=".6f"))