-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix(Mutation): Deeply-nested uid facets #7455
fix(Mutation): Deeply-nested uid facets #7455
Conversation
Hello, I'm looking into this. Just leaving some notes here.
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r3, 2 of 2 files at r4.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @karlmcguire and @nelsonpecora)
go.mod, line 17 at r4 (raw file):
github.com/blevesearch/bleve v1.0.13 github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd github.com/davecgh/go-spew v1.1.1
What's go-spew? I don't see it used in this PR, so why is this dependency added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @karlmcguire and @nelsonpecora)
go.mod, line 17 at r4 (raw file):
Previously, danielmai (Daniel Mai) wrote…
What's go-spew? I don't see it used in this PR, so why is this dependency added?
Nevermind, I see you're using it for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 4 files reviewed, all discussions resolved (waiting on @danielmai and @karlmcguire)
* only run `parseMapFacets` for JSON scalar arrays (cherry picked from commit 5049092)
Cherry-pick of #7455. * only run `parseMapFacets` for JSON scalar arrays (cherry picked from commit 5049092) Co-authored-by: Nelson Pecora <[email protected]> Co-authored-by: Karl McGuire <[email protected]>
Cherry-pick of #7455. * only run `parseMapFacets` for JSON scalar arrays (cherry picked from commit 5049092) Co-authored-by: Nelson Pecora <[email protected]> Co-authored-by: Karl McGuire <[email protected]> (cherry picked from commit e1ee859)
Between v20.03 and v20.11 (with #5424), dgraph lost the ability to handle deeply-nested uid facets. A JSON mutation with non-nested uid facets looks like this:
A mutation with deeply-nested uid facets looks like this:
There's something about trying to set both
children
andchildren|position
on the same JSON object that's causing it to error. The equivalent mutation in RDF succeeds:Fix(karl): The short explanation is there was an old TODO mentioning that we should only run
parseMapFacets
if we are within a JSON scalar array, but we were running it from within JSON object arrays as well. Only running it from within JSON scalar arrays fixed the issue.Longer explanation: By calling
parseMapFacets
from within a JSON object array, the"friend|close": true
facet was correctly assumed to have an object (map) value rather than its scalar value, and this error was returned.The reason
"another_friend|close": true
worked despite this is becauseparseScalarMap
looks for facets on the same level as the predicate. For example, here's how map facets should look:So in the working
another_friend
example,parseMapFacets
is called two times (once for each named JSON array declaration):parseMapFacets(map[string]interface{}{}, "friend|")
mapToNquads
encounters"friend": [
on the current level and callsparseMapFacets
with all facets found on the current level (none) and"friend" + "|"
as theprefix
parameter.m
is empty andparseMapFacets
returnsnil
.parseMapFacets(map[string]interface{}{"friend|close": true}, "another_friend|")
mapToNquads
encounters"another_friend": [
on the current level and callsparseMapFacets
with all facets found on the current level and"another_friend" + "|"
as theprefix
parameter.prefix
(in this case,another_friend|
) is in the facet name (in this case,friend|close
) andparseMapFacets
returnsnil
.So
parseMapFacets
is only called two times, both times returningnil
, and we pick up the facets withparseScalarFacets
later.With this PR fix, we only call
parseMapFacets
for JSON scalar arrays and avoid everything mentioned above.This change is