fix(ddic): Data Preview 400 报错携带 SAP 原文 + 纠正 SQL 方言结论(= 需两侧空格,非不支持)

This commit is contained in:
coordinator
2026-09-11 02:00:50 +08:00
parent 53ea2d854d
commit f9d08774fd
6 changed files with 55 additions and 23 deletions
+15 -4
View File
@@ -3,6 +3,7 @@
from __future__ import annotations
import logging
import re
import xml.etree.ElementTree as ET
from typing import Any
@@ -840,11 +841,21 @@ class DdicMixin:
resp = self.session.post(url, headers=hdrs, params=params, data=sql.encode("utf-8"))
logger.info("QUERY TABLE DATA RESPONSE: HTTP %s", resp.status_code)
if resp.status_code == 400:
raise SapCliError(
"ADT Data Preview 拒绝该 SQLHTTP 400)。本系统 SQL 方言限制:"
"WHERE 只支持 IN(...) / LIKE '...',不支持 '='SELECT 列表必须逗号分隔。"
"请改用 IN / LIKE 重试。"
sap_msg = ""
try:
m = re.search(r"<message[^>]*>(.*?)</message>", resp.text, re.S)
if m:
sap_msg = m.group(1).strip()
except Exception:
pass
hint = (
"ADT Data Preview 拒绝该 SQLHTTP 400)。常见原因:"
"① WHERE 运算符两侧缺空格(写 f = 'x',不要 f='x';多值过滤推荐 IN);"
"② SELECT 列表未用逗号分隔;③ 列名不存在(如 DD02T 的语言列是 DDLANGUAGE)。"
)
if sap_msg:
raise SapCliError(f"{hint}\n SAP 原文: {sap_msg}")
raise SapCliError(hint)
resp.raise_for_status()
root = ET.fromstring(resp.content)