mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
fix: Handling Null Values in SQL Execution Results (#10332)
### What problem does this PR solve? Close #10324 The agent reported an error "undefined" after using the ExeSql tool. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) now: <img width="641" height="687" alt="img" src="https://github.com/user-attachments/assets/eb3bbd27-4cf8-42ce-939c-fc012a93efa0" />
This commit is contained in:
@ -162,6 +162,8 @@ class ExeSQL(ToolBase, ABC):
|
|||||||
if pd.api.types.is_datetime64_any_dtype(df[col]):
|
if pd.api.types.is_datetime64_any_dtype(df[col]):
|
||||||
df[col] = df[col].dt.strftime("%Y-%m-%d")
|
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")))
|
sql_res.append(convert_decimals(df.to_dict(orient="records")))
|
||||||
formalized_content.append(df.to_markdown(index=False, floatfmt=".6f"))
|
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]):
|
if pd.api.types.is_datetime64_any_dtype(single_res[col]):
|
||||||
single_res[col] = single_res[col].dt.strftime('%Y-%m-%d')
|
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')))
|
sql_res.append(convert_decimals(single_res.to_dict(orient='records')))
|
||||||
formalized_content.append(single_res.to_markdown(index=False, floatfmt=".6f"))
|
formalized_content.append(single_res.to_markdown(index=False, floatfmt=".6f"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user