GitHub user wangzhewwzz added a comment to the discussion: 关于电网拓扑数据导入
"field_mapping": { "from": "from", "to": "to" }
哎哟 都说了 这么写会报错 你这AI能不能专注一下问题
原始邮件
发件人:dosubot[bot] ***@***.***>
发件时间:2025年12月11日 11:40
收件人:apache/incubator-hugegraph ***@***.***>
抄送:wangzhewwzz ***@***.***>, Mention ***@***.***>
主题:Re: [apache/incubator-hugegraph] 关于电网拓扑数据导入 (Discussion #2917)
你的 struct_1.json 里 edges 的 field_mapping 必须写成:
"field_mapping": { "from": "from", "to": "to" }
不能写成 { "from": "id", "to": "id" },否则 loader 会把 CSV 的 id 列当作边属性导入,但
schema.groovy 的 edgeLabel 没有声明 id 属性,导致 “Invalid property 'id' for edge label”
或 “主键字段 [id] 为空” 的报错。
如果你已经这样写了但还是报错,请务必检查以下几点:
source/target 配置必须是 "source": ["from"], "target": ["to"],不能写反。
field_mapping 必须是 { "from": "from", "to": "to" },不要有 id。
CSV header 必须严格为 id,from,to,label,source_label,target_label,不能有多余空格或 BOM。
所有 from/to 字段都不能有空值,且和顶点 id 完全一致(无多余空格、无大小写问题、无空行)。
null_values 建议只保留 ["NULL", "null"],不要加 "",否则空字符串会被判定为 null。
schema.groovy 的边标签 .properties() 只包含实际需要的属性(如 "source_label",
"target_label"),不要加 "id"。
如果你已经全部按上述做了,还是报 “Make sure the primary key fields [id] are not empty, or check
whether the headers or field_mapping are configured correctly”,请贴出:
edge_connected_to.csv 的 header 和前 2 行原始数据(不要做任何处理)
struct_1.json 某个 edges 配置的完整内容(尤其是 source/target/field_mapping/value_mapping)
这样我可以帮你定位具体是哪一行或哪一列有问题。
常见坑:
source/target 写反了(比如 "source": ["to"], "target": ["from"])
field_mapping 写成了 id
CSV header 有隐藏字符或 BOM
null_values 配置了空字符串
顶点 id 有重复或空行
只要这几点全部做到,边就能正常导入且无报错,所有关系都能导入。官方FAQ说明
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose |
Hallucination | Report 🐛 | Other
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
GitHub link:
https://github.com/apache/incubator-hugegraph/discussions/2917#discussioncomment-15226382
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]