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

Schema exports predicates that cannot be re-imported. #3699

Closed
danielmai opened this issue Jul 22, 2019 · 0 comments · Fixed by #3700
Closed

Schema exports predicates that cannot be re-imported. #3699

danielmai opened this issue Jul 22, 2019 · 0 comments · Fixed by #3700
Assignees
Labels
kind/bug Something is broken. status/accepted We accept to investigate/work on it.
Milestone

Comments

@danielmai
Copy link
Contributor

If you suspect this could be a bug, follow the template.

  • What version of Dgraph are you using?
    master (a1e3681) and v1.0.16.

  • Have you tried reproducing the issue with latest release?
    Yes

  • Steps to reproduce the issue (command/config used to run Dgraph).

  1. Run Dgraph cluster
  2. Run a mutation to a predicate with only numbers in the name, e.g. <123>:
{
  set {
    _:n <123> "test"^^<xs:string> .
  }
}
  1. Run export curl localhost:8080/admin/export.

  2. The schema file contents look like this:

$ zcat g01.schema.gz 
123:string . 
  1. Run live loader with the exported data and see this error:
$ dgraph live -f g01.rdf.gz -s g01.schema.gz -a localhost:9080 -z localhost:5080
[Decoder]: Using assembly version of decoder
I0722 14:53:03.072148    9624 init.go:93] 

Dgraph version   : v1.0.12-rc3-613-ga1e368193
Commit SHA-1     : a1e368193
Commit timestamp : 2019-07-22 10:46:41 -0700
Branch           : master
Go version       : go1.12.5

For Dgraph official documentation, visit https://docs.dgraph.io.
For discussions about Dgraph     , visit https://discuss.dgraph.io.
To say hi to the community       , visit https://dgraph.slack.com.

Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2018 Dgraph Labs, Inc.



Running transaction with dgraph endpoint: 127.0.0.1:9080

Processing schema file "g01.schema.gz"
Error while processing schema file "g01.schema.gz": rpc error: code = Unknown desc = while lexing 123:default . 
dgraph.type:[string] @index(exact) . 
 at line 1 column 0: Invalid schema. Unexpected 1
  • Expected behaviour and actual result.

I expect that exported data should be able to be re-imported as-is with live loader, bulk loader, or regular client alter and mutate operations.

A fix for this is to export the schema file with predicate names like 123 surrounded with angle brackets to escape them. we do for i18n predicates <>:

<123>:string .
@danielmai danielmai added the kind/bug Something is broken. label Jul 22, 2019
martinmr added a commit that referenced this issue Jul 22, 2019
This change is fixing #3699 for the 1.0 branch. The logic in this branch
was slightly different. In this case, the brackets are only added if
there's a colon in the predicate name. This logic is also buggy as it
doesn't handle predicate names consisting of only numbers.

The fix is to add the brackets for every predicate name for consistency
and simplicity.
@martinmr martinmr self-assigned this Jul 22, 2019
@martinmr martinmr added the status/accepted We accept to investigate/work on it. label Jul 22, 2019
@martinmr martinmr added this to the Dgraph v1.1 milestone Jul 22, 2019
martinmr added a commit that referenced this issue Jul 23, 2019
This change is fixing #3699 for the 1.0 branch. The logic in this branch
was slightly different. In this case, the brackets are only added if
there's a colon in the predicate name. This logic is also buggy as it
doesn't handle predicate names consisting of only numbers.

The fix is to add the brackets for every predicate name for consistency
and simplicity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something is broken. status/accepted We accept to investigate/work on it.
Development

Successfully merging a pull request may close this issue.

2 participants