You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Python SDK recursive CTE flag emits plain WITH and fails on supported recursive query #31241
frommatrixoneimportClientfrommatrixone.ormimportCTEc=Client(sql_log_mode="off")
c.connect(host="127.0.0.1", port=36601, database="mo_catalog", on_connect=[])
body="SELECT 1 AS n UNION ALL SELECT n+1 FROM r WHERE n<3"recursive=CTE("r", body, recursive=True)
print(c.query(recursive)._build_sql())
print(c.query(recursive).all())
The emitted SQL is WITH r AS (SELECT 1 AS n UNION ALL SELECT n+1 FROM r WHERE n<3) SELECT * FROM r.
Actual behavior
QueryError: SQL parser error: not declare RECURSIVE: 'r'.
Expected behavior
The SDK should honor recursive=True and emit a valid WITH RECURSIVE statement, returning rows (1), (2), (3).
Stability and controls
Reproducer: sync 3/3 and async 3/3, each with independent ephemeral CTE names. Both emitted plain WITH and received 1064.
Direct MO control: WITH RECURSIVE r AS (SELECT 1 AS n UNION ALL SELECT n+1 FROM r WHERE n<3) SELECT n FROM r ORDER BY n returned (1),(2),(3) in sync 3/3 and async 3/3.
Ordinary nonrecursive CTE returned (7) in 3/3.
After each sync/async SDK error SELECT 42 returned (42); no persistent object was created.
Evidence
Local scripts and complete output: /private/tmp/mo-sdk-sqlbuilder-20261026/cte_recursive_probe.py and async_recursive_cte_probe.py (rerun with /private/tmp/mo-sdk-py311-venv-20261026/bin/python).
Code analysis
clients/python/matrixone/orm.py:623-626 stores the recursive flag. BaseMatrixOneQuery._build_sql() at orm.py:1412-1422 passes only CTE name/SQL/params into the unified builder. clients/python/matrixone/sql_builder.py:417-423 always prefixes the CTE list with plain WITH. Existing online test clients/python/tests/online/test_orm_cte_integration.py:176-182 merely checks the Python flag and does not execute recursion.
Regression coverage
Add an SDK online test that executes an actual self-referencing CTE, checks exact rows, and verifies a nonrecursive CTE still works.
Local SDK QA (2026-10-26): SDK source 28e8760905a7f39dba2ce436357ea75492f30512; isolated MatrixOne service binary 83c1e23526fc0ed31188abd7fc2ca87cd3a6d4b3 (SHA-256 6bebe05311ae6438967a824641e3849fbbc9af298003177351794601edf14b4b). Passed tests/online/test_sdk_quality_contracts.py::test_native_aliased_dml_and_recursive_cte plus offline recursive CTE contracts. Recursive execution returned exactly [1,2,3]; a nonrecursive control and sync/async entry points were also checked. Focused SDK execution evidence.
核对已合入回归的 SDK 公开入口、SQL/返回值断言和修复后实际服务结果;未修改产品源码,未运行全量 SDK suite 或 race。
回归测试
#31262 已包含 clients/python/tests/online/test_sdk_quality_contracts.py::test_native_aliased_dml_and_recursive_cte。Python SDK API 行为无法由纯 SQL MOTR 代替,未新增 MO 或 MOTR PR。#31262 六个离线 SDK CI job 成功;在线 CI SKIPPED,在线结果采用本地实测。
Activity
fix(python-sdk): unify query contracts and atomic manager operations (#…
XuPeng-SH commentedon Oct 26, 2026
Local SDK QA (2026-10-26): SDK source
28e8760905a7f39dba2ce436357ea75492f30512; isolated MatrixOne service binary83c1e23526fc0ed31188abd7fc2ca87cd3a6d4b3(SHA-2566bebe05311ae6438967a824641e3849fbbc9af298003177351794601edf14b4b). Passedtests/online/test_sdk_quality_contracts.py::test_native_aliased_dml_and_recursive_cteplus offline recursive CTE contracts. Recursive execution returned exactly[1,2,3]; a nonrecursive control and sync/async entry points were also checked. Focused SDK execution evidence.Ariznawlll commentedon Oct 27, 2026
测试版本
420786e21566e5b9d5875e7d6a7f3102fd0761af;修复 PR fix(python-sdk): unify query contracts and atomic manager operations #31262 已 MERGED,merge commit28e8760905a7f39dba2ce436357ea75492f30512已核实在该 main 祖先链。8bd0f1f4c60cd0590c68cdbb2cbca31fc9d39d071ec367ab56d5c49b4eec327e。原问题验证
递归 CTE
WITH RECURSIVE r AS (SELECT 1 ... n<3)经同步/异步公开 Query 执行,结果 n 精确为[1,2,3],不再生成错误的普通 WITH;连续 3 轮通过。Happy Path 覆盖
Unhappy Path 覆盖
ValueError('Joined UPDATE/DELETE'),底表随后仍为预期[(1,4),(2,1),(3,NULL)]。白盒验证
核对已合入回归的 SDK 公开入口、SQL/返回值断言和修复后实际服务结果;未修改产品源码,未运行全量 SDK suite 或 race。
回归测试
#31262 已包含
clients/python/tests/online/test_sdk_quality_contracts.py::test_native_aliased_dml_and_recursive_cte。Python SDK API 行为无法由纯 SQL MOTR 代替,未新增 MO 或 MOTR PR。#31262 六个离线 SDK CI job 成功;在线 CI SKIPPED,在线结果采用本地实测。测试证据
本地 JUnit:
/private/tmp/mo-six-qa-20261026/qa-night/sdk-contract-round-{1,2,3}.xml(每轮 tests=70、失败/错误/跳过均 0)及sdk-offline-round-{1,2,3}.xml(每轮 112、失败/错误/跳过均 0)。修复 PR:#31262 。测试结论
测试通过。