Skip to content

Invalid division by zero #2733

@mehdiym

Description

@mehdiym
  • What version of Dgraph are you using?
    1.0.10

  • Have you tried reproducing the issue with latest release?
    It worked with 1.0.9 but bugs with 1.0.10

  • What is the hardware spec (RAM, OS)?
    Linux Debian Testing, 16GoDDR

  • Steps to reproduce the issue (command/config used to run Dgraph).
    In a query, I do a division and protect potential 0 value for the divisor with a 'max' function.
    The error only happens with value variables, it works with numeric values.
    I also tried to protect the division with a 'cond' without success.

Here is my query:

{
var(func: uid("0xea61")) {
	ct_thinks as count(thinks)
	knows {
		ct_knows as math(1)
	}
	sum_knows as sum(val(ct_knows))
}
me(func: uid("0xea61")) {
	avg: math(ct_thinks / max(1, sum_knows))
}
}
  • Expected behaviour and actual result.
    If sum_knows equals to 0 then avg should be 0.
    If I replace ct_thinks with a literal value, then no more bug.

Metadata

Metadata

Assignees

Labels

kind/bugSomething is broken.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions