dgraph-io/dgraph · error
Equal not supported for type
Error message
Equal not supported for type: %v
What it means
Once types.Equal establishes that both values share a Tid, it only supports equality testing for DateTime, Int, Float, String, Default, Bool and BigFloat. Equality on other types (Uid, binary, etc.) is not defined here and triggers this error.
Solutions
- Compare uids directly as uint64 values instead of via types.Equal
- Restrict the generic Equal path to supported scalar types and special-case others in your code
- Convert binary values to a supported type (e.g. string/Default) before comparing
- Check the predicate's schema type and use the appropriate comparison helper
Example fix
// before
ok, err := types.Equal(a, b) // a.Tid == types.UidID -> error
// after
var ok bool
if a.Tid == types.UidID {
ok = a.Value.(uint64) == b.Value.(uint64)
} else {
ok, err = types.Equal(a, b)
} Defensive patterns
Strategy: type-guard
Validate before calling
switch a.Tid {
case types.UidID, types.BinaryID:
return fmt.Errorf("equality for %s handled separately", a.Tid)
}
ok, err := types.Equal(a, b) Type guard
func equalitySupported(v types.Val) bool {
switch v.Tid {
case types.DateTimeID, types.IntID, types.FloatID, types.StringID, types.DefaultID, types.BoolID, types.BigFloatID:
return true
}
return false
} Try / catch
ok, err := types.Equal(a, b)
if err != nil {
if strings.Contains(err.Error(), "Equal not supported") {
// special-case: compare uids as uint64 or bytes.Equal for binary
}
return err
} Prevention
- Compare uids directly via uint64, not through types.Equal
- Route binary values through bytes.Equal instead of the generic path
- Filter unsupported types out of generic filter/compare pipelines
When it happens
Trigger: Calling types.Equal on same-typed Vals whose Tid is outside the supported set — notably UidID or BinaryID values, e.g. checking equality of two uid Vals through CompareVals or during pagination.
Common situations: Filtering on uid equality through the generic value-comparison path; comparing binary/encrypted values; generic filter code that routes all predicate types through Equal without special-casing uids.
Related errors
- Compare not supported for type
- Arguments of different type can not be compared.
- error interpreting appropriate type for
- got unsupported type for list
- Leaf predicate:' ' must be a scalar.
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/e0824c34f907f077.
Report an issue: GitHub.
Appendix: source
Thrown at types/sort.go:244
// point at which consecutive floats are more than 1 apart).
if a.Tid == FloatID {
return a.Value.(float64) < float64(b.Value.(int64))
}
x.AssertTrue(b.Tid == FloatID)
return float64(a.Value.(int64)) < b.Value.(float64)
}
// Equal returns true if a is equal to b.
func Equal(a, b Val) (bool, error) {
if a.Tid != b.Tid {
return false, errors.Errorf("Arguments of different type can not be compared.")
}
typ := a.Tid
switch typ {
case DateTimeID, IntID, FloatID, StringID, DefaultID, BoolID, BigFloatID:
// Don't do anything, we can sort values of this type.
default:
return false, errors.Errorf("Equal not supported for type: %v", a.Tid)
}
return equal(a, b), nil
}
func equal(a, b Val) bool {
if a.Tid != b.Tid {
return false
}
switch a.Tid {
case DateTimeID:
aVal, aOk := a.Value.(time.Time)
bVal, bOk := b.Value.(time.Time)
return aOk && bOk && aVal.Equal(bVal)
case IntID:
aVal, aOk := a.Value.(int64)
bVal, bOk := b.Value.(int64)
return aOk && bOk && aVal == bVal
case FloatID:View on GitHub (pinned to 759e242be6)