From cf6fd6f1150af6d20c6537edefcaa7f661597383 Mon Sep 17 00:00:00 2001 From: Yao Wei <251109226@qq.com> Date: Wed, 25 Feb 2026 13:36:18 +0800 Subject: [PATCH] fix: When using OceanBase as storage, the list_chunk sorting is abnormal. #13198 (#13208) Actual behavior When using OceanBase as storage, the list_chunk sorting is abnormal. The following is the SQL statement. SELECT id, content_with_weight, important_kwd, question_kwd, img_id, available_int, position_int, doc_type_kwd, create_timestamp_flt, create_time, array_to_string(page_num_int, ',') AS page_num_int_sort, array_to_string(top_int, ',') AS top_int_sort FROM rag_store_284250730805059584 WHERE doc_id = '' AND kb_id IN ('') ORDER BY page_num_int_sort ASC, top_int_sort ASC, create_timestamp_flt DESC LIMIT 0, 20 image Co-authored-by: Aron.Yao --- rag/svr/task_executor.py | 2 +- rag/utils/ob_conn.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rag/svr/task_executor.py b/rag/svr/task_executor.py index 7af52adf8e..4b8a272891 100644 --- a/rag/svr/task_executor.py +++ b/rag/svr/task_executor.py @@ -897,7 +897,7 @@ async def insert_chunks(task_id, task_tenant_id, task_dataset_id, chunks, progre flds = list(mom_ck.keys()) for fld in flds: if fld not in ["id", "content_with_weight", "doc_id", "docnm_kwd", "kb_id", "available_int", - "position_int"]: + "position_int", "create_timestamp_flt", "page_num_int", "top_int"]: del mom_ck[fld] mothers.append(mom_ck) diff --git a/rag/utils/ob_conn.py b/rag/utils/ob_conn.py index e20f8993ec..1ee47aceb8 100644 --- a/rag/utils/ob_conn.py +++ b/rag/utils/ob_conn.py @@ -986,7 +986,7 @@ class OBConnection(OBConnectionBase): for field, order in order_by.fields: if isinstance(column_types[field], ARRAY): f = field + "_sort" - fields_expr += f", array_to_string({field}, ',') AS {f}" + fields_expr += f", array_avg({field}) AS {f}" field = f order = "ASC" if order == 0 else "DESC" orders.append(f"{field} {order}")