Repository navigation
Description
DRAFT 18 (SDK, 2026-10-27) — to be filed
Title: [Bug]: read_json accepts lines=/orient= but ignores lines and maps unsupported orients silently
Description
LoadDataManager.read_json (load_data.py) is documented as pandas-compatible (the parameter names come straight from pandas.read_json: lines, orient, compression). The actual handling:
def read_json(self, filepath_or_buffer, table, lines: bool = True, orient='records', compression=None, inline=False, **kwargs):
...
if inline:
return self.read_json_inline(data=filepath_or_buffer, table=table, orient=orient, **kwargs)
if orient == 'records':
structure_str = 'object'
elif orient == 'values':
structure_str = 'array'
else:
structure_str = 'object' # silently default every other orient
return self.from_file(..., format=LoadDataFormat.JSONLINE.value, jsondata=structure_str, ...)Two contract breaks:
linesis never referenced in the body — it is silently discarded. In pandas,lines=Truemeans JSON-Lines,lines=False(withorient='records') means a standard JSON array file ([{"a":1},{"a":2}]). The SDK always loads as JSONLINE/jsondata=object, so a plain records-array file (the most common single-file export shape from json.dump and from other databases' export tools) fails or misparses while the caller explicitly saidlines=False— the parameter that would have selected the right format does nothing.- Every orient besides 'records'/'values' silently becomes 'object' — pandas'
orient='split'([columns/data shape]),'index','columns','table'each have well-defined layouts; users passing them get the default mapping with no warning, so a split-oriented export loads as garbage/errors with zero hint at the cause. (pandas would honor or at least error on unknown combos.)
Also read_json_inline mirrors the same mapping (orient → jsontype_str with the same silent else-branch), and neither path validates that orient='values'-loaded arrays actually pair with a table whose column order matches — secondary, but part of the same "pandas-flavored but not pandas-semantics" gap.
Reproduction
# standard JSON array file (written by json.dump(records_list, f))
client.load_data.read_json('events.json', table='events', lines=False)
# treated identically to lines=True: JSONLINE format, jsondata=object
# → parse error / truncated load, despite lines=False explicitly requesting array semantics
client.load_data.read_json('split.json', table='t', orient='split')
# silently loaded with jsondata=object — no error naming the unsupported orientImpact
- pandas users porting ingestion code (a stated goal of the API naming) get wrong behavior exactly when they've read the docs and set the right flag (
lines=False). Failures surface as server-side parse errors (or partial data) far from the misleading parameter. orientvalues that could be supported by mapping (split→ array-of-rows after transpose is not even attempted) are silently misinterpreted rather than raising.- Silent-parameter-drop is the recurring SDK disease (see also stage
enabledropped — filed today); this instance blocks a primary ingest format.
Expected behavior
- Honor
lines=False+orient='records'by loading as a standard JSON array (server JSONLINE format with jsondata=object expects line-delimited objects; array files need either jsondata='array' or a pre-pass — either the server's array mode or a documented, raised NotImplementedError). - Raise
ValueError(f"unsupported orient={orient!r}")for orients with no defined mapping instead of defaulting. - Either implement the remaining pandas orients or strike them from the docstring.
- Tests:
lines=Falseloads[{...}]file correctly;orient='split'raises;lines=True(JSONL) unchanged.
Activity
Ariznawlll commentedon Oct 29, 2026
结论
测试不通过。当前 main 的实际服务验证确认
lines=False仍未生效,标准 JSON 数组无法通过该入口导入;这是本 issue 的原有问题,不重复提单。关键证据
main@c6683bd2f531dcaa80e153c0924dac619c49dc9d,同提交构建的隔离双 CN,仓库 Python SDK;3 个新建库,分别测试同步和异步入口。[{"id":1,"v":"alpha"},{"id":2,"v":"beta"}],目标为id INT PRIMARY KEY, v VARCHAR(20)。调用read_json(path, table=..., lines=False, orient='records'),6/6 报 20301invalid input: not a object;目标均保持空表,随后SELECT 1正常。lines=True, orient='records',同步/异步 6/6 精确导入两行;逐行数组加orient='values'也 6/6 正确。对象文件误指定orient='values'时 6/6 拒绝且目标空表。format='jsonline', jsondata='object';本次结果支持原 issue 中lines未生效的判断,不宣称其他 orient 或半途失败场景也已验证。精确记录为本地sdk_json4_probe.json与sdk_json4_probe_2.log,代码入口见 load_data.py。待解决点
lines=False给出清晰拒绝,并分别覆盖同步、异步、正常 JSON Lines 与失败后目标状态。fix(python): unify SDK query and analytics lifecycle contracts (#31774)
XuPeng-SH commentedon Oct 30, 2026
QA handoff for merged #31774 (main
bbfe55669a1440424914d45a283a1d0e36f722fa): please verify JSON lines/orient handling, unsupported inputs and target-table atomicity. This isolated QA run inspected the issue and merged source but did not run tests or a live MatrixOne service at this SHA because resource headroom under the existing guard was insufficient. Earlier QA counterexamples and PR author-reported validation remain scoped to their recorded versions and are not results of this QA run.Ariznawlll commentedon Oct 30, 2026
结论
测试通过。
read_json对不支持的非 JSON Lines 输入和 orient 明确拒绝,支持的 JSON Lines 导入仍正常;这次验收的是明确拒绝方案,不表示已支持普通 JSON 数组文件。关键证据
main@d39d8a40343ccd40bf665036388df7a40ee867f8;修复 PR fix(python): unify SDK query and analytics lifecycle contracts #31774 合并提交bbfe55669a1440424914d45a283a1d0e36f722fa位于其祖先链;实际运行二进制和 SDK 源码与完整 SHA 一致。本地隔离 1 CN / 1 TN / 1 LogService,Python 3.12,客户端与 CN 共用测试文件目录。lines=False,以及orient='split'、orient='unknown',同步和异步接口均在写入前抛ValueError;每次拒绝后目标表仍为空。(1,'alpha'),(2,'beta'),SELECT 1正常;每轮测试文件和库均清理。待解决点