apache / apache/hugegraph-toolchain

[Bug] Loader error when not specify pk as id

Open
#503 0 comments 1 reaction 1 assignee Claimed by @liuxiaocs7 View on GitHub
bug
Dominant language
Java
Stars
121
Forks
125
Avg merge
10d 10h
Merged PRs (30d)
3

Description

### Bug Type (问题类型)

exception / error (异常报错)

schema set `name` as pk in label `person`, exec by hg-client to server.

```
schema.vertexLabel("person")
.properties("name", "age", "city")
.primaryKeys("name")
.nullableKeys("age", "city")
.ifNotExist()
.create();
```

loader struct conf, not specify `id`, but got `Can't customize vertex id when id strategy is 'PRIMARY_KEY' for vertex label 'person'`

```
"vertices": [
{
"label": "person",
"input": {
"type": "file",
"path": "example/spark/vertex_person.json",
"format": "JSON",
"header": ["name", "age", "city"],
"charset": "UTF-8",
"skipped_line": {
"regex": "(^#|^//).*"
}
},
"null_values": ["NULL", "null", ""]
}
```

### Before submit

- [X] I had searched in the [issues](https://github.com/apache/hugegraph-toolchain/issues) and found no similar issues.

### Environment (环境信息)

- Server Version: v1.0.0
- Toolchain Version: master
- Data Size: xx vertices, xx edges

### Expected & Actual behavior (期望与实际表现)

```
class java.lang.IllegalArgumentException: Can't customize vertex id when id strategy is 'PRIMARY_KEY' for vertex label 'person'
at org.apache.hugegraph.exception.ServerException.fromResponse(ServerException.java:45)
at org.apache.hugegraph.client.RestClient.checkStatus(RestClient.java:91)
at org.apache.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:232)
at org.apache.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:212)
at org.apache.hugegraph.api.graph.VertexAPI.create(VertexAPI.java:58)
```

### Vertex/Edge example (问题点 / 边数据举例)

_No response_

### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

```grovvy
// Define schema
schema.propertyKey("name").asText().ifNotExist().create();
schema.propertyKey("age").asInt().ifNotExist().create();
schema.propertyKey("city").asText().ifNotExist().create();
schema.propertyKey("weight").asDouble().ifNotExist().create();
schema.propertyKey("lang").asText().ifNotExist().create();
schema.propertyKey("date").asText().ifNotExist().create();
schema.propertyKey("price").asDouble().ifNotExist().create();

schema.vertexLabel("person")
.properties("name", "age", "city")
.primaryKeys("name")
.nullableKeys("age", "city")
.ifNotExist()
.create();

schema.vertexLabel("software")
.properties("name", "lang", "price")
.useCustomizeStringId()
.ifNotExist()
.create();

schema.edgeLabel("knows")
.sourceLabel("person")
.targetLabel("person")
.properties("date", "weight")
.ifNotExist()
.create();

schema.edgeLabel("created")
.sourceLabel("person")
.targetLabel("software")
.properties("date", "weight")
.ifNotExist()
.create();
```

```bash
{
"vertices": [
{
"label": "person",
"input": {
"type": "file",
"path": "example/spark/vertex_person.json",
"format": "JSON",
"header": ["name", "age", "city"],
"charset": "UTF-8",
"skipped_line": {
"regex": "(^#|^//).*"
}
},
"null_values": ["NULL", "null", ""]
},
{
"label": "software",
"input": {
"type": "file",
"path": "example/spark/vertex_software.json",
"format": "JSON",
"header": ["id","name", "lang", "price","ISBN"],
"charset": "GBK"
},
"id": "name",
"ignored": ["ISBN"]
}
],
"edges": [
{
"label": "knows",
"source": ["source_name"],
"target": ["target_name"],
"input": {
"type": "file",
"path": "example/spark/edge_knows.json",
"format": "JSON",
"date_format": "yyyyMMdd",
"header": ["source_name","target_name", "date", "weight"]
},
"field_mapping": {
"source_name": "name",
"target_name": "name"
}
}
]
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.