Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Loader error when not specify pk as id #503

Open
1 task done
liuxiaocs7 opened this issue Aug 3, 2023 · 0 comments
Open
1 task done

[Bug] Loader error when not specify pk as id #503

liuxiaocs7 opened this issue Aug 3, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@liuxiaocs7
Copy link
Member

liuxiaocs7 commented Aug 3, 2023

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

  • I had searched in the 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] (元数据结构)

// 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();
{
  "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"
      }
    }
  ]
}
@liuxiaocs7 liuxiaocs7 added the bug Something isn't working label Aug 3, 2023
@liuxiaocs7 liuxiaocs7 changed the title [Bug] Loader [Bug] Loader error when not specify pk as id Aug 3, 2023
@liuxiaocs7 liuxiaocs7 self-assigned this Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant