Conflict names causing same color to different predicated

Moved from GitHub ratel/149

Posted by ptsilva:

I think the ratel it’s confusing with same prefix of predicates:
Queries showed are equals, changing only predicates aliases.
All predicates have records.

Note that in first image, both predicates pessoa.recebeu_empenho and pessoa.emitiu_nota_fisical has same prefix, then UI ratel aliased predicates to pe.

For testing, also tried alias to same name of predicate, wrong colors also happen:

Here we force a alias, then colors works as expected.

Even using more adequate names for predicate, always that prefix conflict happen, also happen colors confusion.

paulftw commented :

Thank you for taking your time to write a very detailed bug report.

I’m having difficulties reproducing it on a test dataset though, so need to clarify a few things:

  1. Are you sure you are running the latest Ratel version? Is the bug present on https://play.dgraph.io ?
  2. Are there any non-latin characters in the predicate names you are using? I’ve copy-pasted the names you’ve provided, but maybe your dataset has umlauts or something? (sorry I have no idea what language is that and what alphabet it uses)
  3. If two different predicates are pointing to the same uid Ratel may visualize only one of the relationships. (e.g. <:Alice> <:Bob> and also <:Alice> <:Bob>). Can this be the case in your failing tests?

Test mutation I’ve used:

{
  set {
    <_:a> <pessoa.recebeu_empenho> <_:b> .
    <_:a> <pessoa.emitiu_nota_fisical> <_:c> .

    <_:a> <pessoa.recebeu_empenho> <_:d> .
    <_:a> <pessoa.emitiu_nota_fisical> <_:e> .
  }
}

Test query:

{
  q(func: has(pessoa.recebeu_empenho)) {
    uid,
    pessoa.recebeu_empenho {
      uid
    },
    pessoa.emitiu_nota_fisical {
      uid
    },
  }
}

Result seems correct to me:

ptsilva commented :

I’ve tried reproduce the issue and i noticed that maybe it’s issue is not related with colors, but related with limit of showing node and ordering of result.

Try this on https://play.dgraph.io/:

  1. Query without alias:
{
  node(func: uid(0x234)) {
    uid
    starring {
        uid
    }
    other_crew {
        uid
    }
  }
}
  1. Alias that preserve result ordering. Has a same nodes that previous query
{
  node(func: uid(0x234)) {
    uid
    b: starring {
        uid
    }
    a: other_crew {
        uid
    }
  }
}
  1. Query changing the result ordering
{
  node(func: uid(0x234)) {
    uid
    a: starring {
        uid
    }
    b: other_crew {
        uid
    }
  }
}

I think that rename predicates cause reordering of results. Testing a query direct in dgraph (reordering is not applied without/with predicate alias), i think that is ratel related and maybe it’s not a issue, but probably it’s causes confusion.

What do you think about it?

paulftw commented :

@ptsilva can you please try this query:

{
  node(func: eq(pessoa.cpf_cnpj, "xxxx")) {
    b: pessoa.recebeu_empenho {
      uid
    },
    a: pessoa.emitiu_nota_fisical {
      uid
    },
}

I have swapped a and b to make sure alphabetic order of predicates is same as your original query. If this new query produces a graph with only green edges we have a confirmation that this is due to ordering of nodes in the response.

I cannot explain why forcing aliases would cause nodes to be returned in a different order, but that behavior would definitely explain the coloring difference, and would not be a bug. Will ask the backend team about this

ptsilva commented :

I’ve changed my previous comment exactly changing the alias alphabetically

ptsilva commented :

I think that is not a ordering of nodes in response. I’ve tried query in dgraph http and result seems preserve ordering with and without alias.

ptsilva commented :

Could be related with JSON parse of result.

paulftw commented :

I couldn’t find a way to reproduce this issue, so will close the bug as stale.

If it is still happening please re-open.

I think most likely it was due to expansion order on big graphs, because we have code to avoid prefix conflicts: ratel/GraphLabeler.js at 1d98cc18bc80e402fae7dd8a58bc1592392f9e79 · dgraph-io/ratel · GitHub