GitHub user dosubot[bot] added a comment to the discussion: 关于电网拓扑数据导入

<!-- Answer -->
你的配置现在只差一个关键点就能导入成功,但你还遗漏了最核心的地方:

**你的 struct.json 里所有 edges 的 field_mapping 必须写成:**
```json
"field_mapping": { "from": "from", "to": "to" }
```
而且 **不能写成** `{ "from": "id", "to": "id" }` 或 `{ "from": "id", "to": "id", ... 
}`,否则 loader 会把 CSV 的 id 列当作边属性导入,但 schema.groovy 的 edgeLabel 没有声明 id 属性,导致 
“Invalid property 'id' for edge label” 或 “主键字段 [id] 为空” 
的报错。[官方文档说明](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/quickstart/toolchain/hugegraph-loader.md#L705-L1064)

**你现在遇到的 “Make sure the primary key fields [id] are not empty, or check whether 
the headers or field_mapping are configured correctly” 报错,根本原因是:**
- 你的顶点主键是 id(vertex_xxx.csv 里有 id 列,schema 里 primaryKeys("id")),loader 只会用 
from/to 字段的值直接作为顶点主键 id,不会再去查 vertex_xxx.csv 的其他字段。
- edge_connected_to.csv 的 id 列可以保留,但 loader 不会导入它为边属性,只要 field_mapping 不写 id 
就不会报错。
- edgeLabel 的 .properties() 只包含 "source_label", "target_label",不要加 "id"。
- value_mapping 必须是平铺结构(你现在的写法没问题)。
- null_values 建议只保留 ["NULL", "null"],不要加 "",否则空字符串会被判定为 null。

**请你务必检查:**
1. struct.json 里所有 edges 的 field_mapping 都是 `"field_mapping": { "from": "from", 
"to": "to" }`,没有任何 id。
2. edge_connected_to.csv 的 from/to 字段和所有顶点 id 完全一致(无多余空格、无大小写问题、无空行)。
3. struct.json 的 null_values 只保留 ["NULL", "null"],不要加 ""。
4. edgeLabel 的 .properties() 只包含 "source_label", "target_label",不要加 "id"。
5. 你可以加 `"selected": ["from", "to"]` 显式指定用到的字段,避免 loader 解析其它无关列。

**如果还有报错,请贴出 power_edges_to.csv 的 header 和前几行原始数据,以及 struct.json 某个 edges 
配置的完整内容,我可以帮你定位具体是哪一行或哪一列有问题。**

只要这几点全部做到,边就能正常导入且无报错,所有关系都能导入。[官方FAQ说明](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/guides/faq.md)


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/17a00ddc-43bf-46d2-a63a-11c737a46136?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/17a00ddc-43bf-46d2-a63a-11c737a46136?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/17a00ddc-43bf-46d2-a63a-11c737a46136?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/17a00ddc-43bf-46d2-a63a-11c737a46136?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/17a00ddc-43bf-46d2-a63a-11c737a46136?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/17a00ddc-43bf-46d2-a63a-11c737a46136?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/17a00ddc-43bf-46d2-a63a-11c737a46136?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/e5e246fa-a522-4d8a-ab3c-e2588b5b501b/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=%E4%BD%A0%E7%9A%84%E9%85%8D%E7%BD%AE%E7%8E%B0%E5%9C%A8%E5%8F%AA%E5%B7%AE%E4%B8%80%E4%B8%AA%E5%85%B3%E9%94%AE%E7%82%B9%E5%B0%B1%E8%83%BD%E5%AF%BC%E5%85%A5%E6%88%90%E5%8A%9F%EF%BC%8C%E4%BD%86%E4%BD%A0%E8%BF%98%E9%81%97%E6%BC%8F%E4%BA%86%E6%9C%80%E6%A0%B8%E5%BF%83%E7%9A%84%E5%9C%B0%E6%96%B9%EF%BC%9A%0A%0A%2A%2A%E4%BD%A0%E7%9A%84%20struct.json%20%E9%87%8C%E6%89%80%E6%9C%89%20edges%20%E7%9A%84%20field_mapping%20%E5%BF%85%E9%A1%BB%E5%86%99%E6%88%90%EF%BC%9A%2A%2A%0A%60%60%60json%0A%22field_mapping%22%3A%20%7B%20%22from%22%3A%20%22from%22%2C%20%22to%22%3A%20%22to%22%20%7D%0A%60%60%60%0A%E8%80%8C%E4%B8%94%20%2A%2A%E4%B8%8D%E8%83%BD%E5%86%99%E6%88%90%2A%2A%20%60%7B%20%22from%22%3A%20%22id%22%2C%20%22to%22%3A%20%22id%22%20%7D%60%20%E6%88%96%20%60%7B%20%22from%2
 
2%3A%20%22id%22%2C%20%22to%22%3A%20%22id%22%2C%20...%20%7D%60%EF%BC%8C%E5%90%A6%E5%88%99%20loader%20%E4%BC%9A%E6%8A%8A%20CSV%20%E7%9A%84%20id%20%E5%88%97%E5%BD%93%E4%BD%9C%E8%BE%B9%E5%B1%9E%E6%80%A7%E5%AF%BC%E5%85%A5%EF%BC%8C%E4%BD%86%20schema.groovy%20%E7%9A%84%20edgeLabel%20%E6%B2%A1%E6%9C%89%E5%A3%B0%E6%98%8E%20id%20%E5%B1%9E%E6%80%A7%EF%BC%8C%E5%AF%BC%E8%87%B4%20%E2%80%9CInvalid%20property%20%27id%27%20for%20edge%20label%E2%80%9D%20%E6%88%96%20%E2%80%9C%E4%B8%BB%E9%94%AE%E5%AD%97%E6%AE%B5%20%5Bid%5D%20%E4%B8%BA%E7%A9%BA%E2%80%9D%20%E7%9A%84%E6%8A%A5%E9%94%99%E3%80%82%5B%E5%AE%98%E6%96%B9%E6%96%87%E6%A1%A3%E8%AF%B4%E6%98%8E%5D%28https%3A//github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/quickstart/toolchain/hugegraph-loader.md%23L705-L1064%29%0A%0A%2A%2A%E4%BD%A0%E7%8E%B0%E5%9C%A8%E9%81%87%E5%88%B0%E7%9A%84%20%E2%80%9CMake%20sure%20the%20primary%20key%20fields%20%5Bid%5D%20are%20not%20empty%2C%20or%20check%20whether%20the%20headers%20or%20field_mapping%20are%
 
20configured%20correctly%E2%80%9D%20%E6%8A%A5%E9%94%99%EF%BC%8C%E6%A0%B9%E6%9C%AC%E5%8E%9F%E5%9B%A0%E6%98%AF%EF%BC%9A%2A%2A%0A-%20%E4%BD%A0%E7%9A%84%E9%A1%B6%E7%82%B9%E4%B8%BB%E9%94%AE%E6%98%AF%20id%EF%BC%88vertex_xxx.csv%20%E9%87%8C%E6%9C%89%20id%20%E5%88%97%EF%BC%8Cschema%20%E9%87%8C%20primaryKeys%28%22id%22%29%EF%BC%89%EF%BC%8Cloader%20%E5%8F%AA%E4%BC%9A%E7%94%A8%20from/to%20%E5%AD%97%E6%AE%B5%E7%9A%84%E5%80%BC%E7%9B%B4%E6%8E%A5%E4%BD%9C%E4%B8%BA%E9%A1%B6%E7%82%B9%E4%B8%BB%E9%94%AE%20id%EF%BC%8C%E4%B8%8D%E4%BC%9A%E5%86%8D%E5%8E%BB%E6%9F%A5%20vertex_xxx.csv%20%E7%9A%84%E5%85%B6%E4%BB%96%E5%AD%97%E6%AE%B5%E3%80%82%0A-%20edge_connected_to.csv%20%E7%9A%84%20id%20%E5%88%97%E5%8F%AF%E4%BB%A5%E4%BF%9D%E7%95%99%EF%BC%8C%E4%BD%86%20loader%20%E4%B8%8D%E4%BC%9A%E5%AF%BC%E5%85%A5%E5%AE%83%E4%B8%BA%E8%BE%B9%E5%B1%9E%E6%80%A7%EF%BC%8C%E5%8F%AA%E8%A6%81%20field_mapping%20%E4%B8%8D%E5%86%99%20id%20%E5%B0%B1%E4%B8%8D%E4%BC%9A%E6%8A%A5%E9%94%99%E3%80%82%0A-%20edgeLabel%20%E7%9A%84%20.properties%28
 
%29%20%E5%8F%AA%E5%8C%85%E5%90%AB%20%22source_label%22%2C%20%22target_label%22%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%8A%A0%20%22id%22%E3%80%82%0A-%20value_mapping%20%E5%BF%85%E9%A1%BB%E6%98%AF%E5%B9%B3%E9%93%BA%E7%BB%93%E6%9E%84%EF%BC%88%E4%BD%A0%E7%8E%B0%E5%9C%A8%E7%9A%84%E5%86%99%E6%B3%95%E6%B2%A1%E9%97%AE%E9%A2%98%EF%BC%89%E3%80%82%0A-%20null_values%20%E5%BB%BA%E8%AE%AE%E5%8F%AA%E4%BF%9D%E7%95%99%20%5B%22NULL%22%2C%20%22null%22%5D%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%8A%A0%20%22%22%EF%BC%8C%E5%90%A6%E5%88%99%E7%A9%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%BC%9A%E8%A2%AB%E5%88%A4%E5%AE%9A%E4%B8%BA%20null%E3%80%82%0A%0A%2A%2A%E8%AF%B7%E4%BD%A0%E5%8A%A1%E5%BF%85%E6%A3%80%E6%9F%A5%EF%BC%9A%2A%2A%0A1.%20struct.json%20%E9%87%8C%E6%89%80%E6%9C%89%20edges%20%E7%9A%84%20field_mapping%20%E9%83%BD%E6%98%AF%20%60%22field_mapping%22%3A%20%7B%20%22from%22%3A%20%22from%22%2C%20%22to%22%3A%20%22to%22%20%7D%60%EF%BC%8C%E6%B2%A1%E6%9C%89%E4%BB%BB%E4%BD%95%20id%E3%80%82%0A2.%20edge_connected_to.csv%20%E7%9A%84%20from/to%2
 
0%E5%AD%97%E6%AE%B5%E5%92%8C%E6%89%80%E6%9C%89%E9%A1%B6%E7%82%B9%20id%20%E5%AE%8C%E5%85%A8%E4%B8%80%E8%87%B4%EF%BC%88%E6%97%A0%E5%A4%9A%E4%BD%99%E7%A9%BA%E6%A0%BC%E3%80%81%E6%97%A0%E5%A4%A7%E5%B0%8F%E5%86%99%E9%97%AE%E9%A2%98%E3%80%81%E6%97%A0%E7%A9%BA%E8%A1%8C%EF%BC%89%E3%80%82%0A3.%20struct.json%20%E7%9A%84%20null_values%20%E5%8F%AA%E4%BF%9D%E7%95%99%20%5B%22NULL%22%2C%20%22null%22%5D%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%8A%A0%20%22%22%E3%80%82%0A4.%20edgeLabel%20%E7%9A%84%20.properties%28%29%20%E5%8F%AA%E5%8C%85%E5%90%AB%20%22source_label%22%2C%20%22target_label%22%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%8A%A0%20%22id%22%E3%80%82%0A5.%20%E4%BD%A0%E5%8F%AF%E4%BB%A5%E5%8A%A0%20%60%22selected%22%3A%20%5B%22from%22%2C%20%22to%22%5D%60%20%E6%98%BE%E5%BC%8F%E6%8C%87%E5%AE%9A%E7%94%A8%E5%88%B0%E7%9A%84%E5%AD%97%E6%AE%B5%EF%BC%8C%E9%81%BF%E5%85%8D%20loader%20%E8%A7%A3%E6%9E%90%E5%85%B6%E5%AE%83%E6%97%A0%E5%85%B3%E5%88%97%E3%80%82%0A%0A%2A%2A%E5%A6%82%E6%9E%9C%E8%BF%98%E6%9C%89%E6%8A%A5%E9%94%99%EF%BC%8C%
 
E8%AF%B7%E8%B4%B4%E5%87%BA%20power_edges_to.csv%20%E7%9A%84%20header%20%E5%92%8C%E5%89%8D%E5%87%A0%E8%A1%8C%E5%8E%9F%E5%A7%8B%E6%95%B0%E6%8D%AE%EF%BC%8C%E4%BB%A5%E5%8F%8A%20struct.json%20%E6%9F%90%E4%B8%AA%20edges%20%E9%85%8D%E7%BD%AE%E7%9A%84%E5%AE%8C%E6%95%B4%E5%86%85%E5%AE%B9%EF%BC%8C%E6%88%91%E5%8F%AF%E4%BB%A5%E5%B8%AE%E4%BD%A0%E5%AE%9A%E4%BD%8D%E5%85%B7%E4%BD%93%E6%98%AF%E5%93%AA%E4%B8%80%E8%A1%8C%E6%88%96%E5%93%AA%E4%B8%80%E5%88%97%E6%9C%89%E9%97%AE%E9%A2%98%E3%80%82%2A%2A%0A%0A%E5%8F%AA%E8%A6%81%E8%BF%99%E5%87%A0%E7%82%B9%E5%85%A8%E9%83%A8%E5%81%9A%E5%88%B0%EF%BC%8C%E8%BE%B9%E5%B0%B1%E8%83%BD%E6%AD%A3%E5%B8%B8%E5%AF%BC%E5%85%A5%E4%B8%94%E6%97%A0%E6%8A%A5%E9%94%99%EF%BC%8C%E6%89%80%E6%9C%89%E5%85%B3%E7%B3%BB%E9%83%BD%E8%83%BD%E5%AF%BC%E5%85%A5%E3%80%82%5B%E5%AE%98%E6%96%B9FAQ%E8%AF%B4%E6%98%8E%5D%28https%3A//github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/guides/faq.md%29)&nbsp;[![Join
 Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoCol
 or=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-hugegraph/discussions/2917)

GitHub link: 
https://github.com/apache/incubator-hugegraph/discussions/2917#discussioncomment-15216084

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to