Dgraph version: Standalone:latest
Steps to reproduce:
Schema:
<dgraph.cors>: [string] @index(exact) @upsert .
<dgraph.graphql.schema>: string .
<dgraph.graphql.schema_created_at>: datetime .
<dgraph.graphql.schema_history>: string .
<dgraph.graphql.xid>: string @index(exact) @upsert .
<experimentName>: string @index(exact) .
<name>: string @index(exact) .
<option1>: [uid] .
<option2>: [uid] .
<result>: [uid] @count @reverse .
type <dgraph.graphql> {
dgraph.graphql.schema
dgraph.graphql.xid
}
type <dgraph.graphql.history> {
dgraph.graphql.schema_history
dgraph.graphql.schema_created_at
}
Mutation:
{
set{
_:exp <name> "experiment" .
_:exp <option1> _:heads .
_:exp <option2> _:tails .
_:heads <name> "heads" .
_:tails <name> "tails" .
_:exp1 <result> _:heads .
_:exp2 <result> _:heads .
_:exp3 <result> _:heads .
_:exp4 <result> _:heads .
_:expt1 <result> _:tails .
_:expt2 <result> _:tails .
_:expt3 <result> _:tails .
_:expt4 <result> _:tails .
}
}
Query:
{
q(func: eq(name, "experiment")) {
option1{
h as count(~result)
}
h1 as max(val(h))
option2{
t as count(~result)
}
t1 as max(val(t))
total as math( h1 + t1)
prob_heads: math( (h1*100) / total )
result1 : math ( 4*100 / 8 )
result2 : math ( (4*100) / 8 )
}
}
Result:
{
"data": {
"q": [
{
"option1": [
{
"count(~result)": 4
}
],
"max(val(h))": 4,
"option2": [
{
"count(~result)": 4
}
],
"max(val(t))": 4,
"val(total)": 8,
"prob_heads": 50,
"result1": 48,
"result2": 50
}
]
}
}
Bug: Please note the difference between result1 and result2 (the rest can be effectively ignored, using variables instead of hard-coded numbers also results in the same bug). It should be the same, as it looks to be the same expression essentially.