Input for predicate "location" of type scalar is uid

Report a Dgraph Bug

What version of Dgraph are you using?

v20.07.0

Have you tried reproducing the issue with the latest release?

yes

What is the hardware spec (RAM, OS)?

Client: MacOS 10.13.6 16 GByte RAM
Server: Ubuntu 18.04 LTS 64 GByte RAM

Steps to reproduce the issue (command/config used to run Dgraph).

def testCities(self):
        '''
        test a list of cities
        '''
        cityJsonUrl="https://raw.githubusercontent.com/lutangar/cities.json/master/cities.json"
        with urllib.request.urlopen(cityJsonUrl) as url:
            cityList=json.loads(url.read().decode())
        self.assertEqual(128769,(len(cityList)))
        cityIter=iter(cityList)
        limit=1000
        if getpass.getuser()=="travis":
            limit=10000
        for i in range(limit):
            city=next(cityIter)
            city['dgraph.type']='City'
            lat=city['lat']
            lng=city['lng']
            city['location']={'type': 'Point', 'coordinates': [lng,lat] }
            #print("%d: %s" % (i,city))
        dgraph=self.getDGraph()
        dgraph.drop_all()
        schema='''
name: string @index(exact) .
country: string .   
lat: float .
lng: float .
location: geo .
type City {
   name
   country
   lat
   lng
   location
}'''
        dgraph.addSchema(schema)
        dgraph.addData(obj=cityList,limit=limit,batchSize=250)
        query='''{ 
  # get cities
  cities(func: has(name)) {
        country
        name
        lat
        lng
        location
  }
}
        '''
        queryResult=dgraph.query(query)
        self.assertTrue('cities' in queryResult)
        qCityList=queryResult['cities']
        self.assertEqual(limit,len(qCityList))
        dgraph.close()

see https://github.com/WolfgangFahl/DgraphAndWeaviateTest/blob/master/tests/testDgraph.py

Expected behaviour and actual result.

Location handling should work or give an understandable error message.
actual error message is:

grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
	status = StatusCode.UNKNOWN
	details = "Input for predicate "location" of type scalar is uid. Edge: entity:16515 attr:"location" value_type:UID value_id:16514 "
	debug_error_string = "{"created":"@1597226020.750128000","description":"Error received from peer ipv6:[2003:c5:b70c:d00:7994:148e:9f98:bd94]:9080","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"Input for predicate "location" of type scalar is uid. Edge: entity:16515 attr:"location" value_type:UID value_id:16514 ","grpc_status":2}"
>

the other example “testCountries” works fine.

{ 
  # get locations
  locations(func: has(name)) {
        country
        name
        lat
        lng
        location
  }
}

grafik

The coordinates are expected as floats:

  lat=float(city['lat'])
  lng=float(city['lng'])

grafik

Please:

  • fix the error message to state the real problem e.g. “coordinates are expected to be floats”
  • better even: accept string versions of the coordinates and automatically convert to floats

Are you running the schema definition before any other procedure? You should make sure. For some reason, Dgraph has inferred your mutation and defined the location as an UID. You see this error cuz of that. You should define it before any mutation.

BTW, Dgraph supports Geo-Type. You should use it instead of a custom one in my opinion.

thx for looking into this. So how is the error going to be fixed? What is going to happen to fix dgraph and improve it? I have been trying dgraph now for almost a week and the experience was full of frustrations based on inconsistencies, uncomprehensible errore messages and the like. I’d appreciate if you take bug reports like this one a lot more serious. If you want to have happy users there needs to be a lot more consistency and understandability… Please also look into my example in more detail and you’ll find that i am using the geo type. I kept the lat/lng values only for debugging why dgraph behaved so badly / weird.

I also think you should not use discuss for bug tracking. Github issues is much easier to use and there is the option of cross-referencing bugs between projects. E.g. my test project GitHub - WolfgangFahl/DgraphAndWeaviateTest: Test GraphQL based Dgraph and Weaviate systems is on github and i could report issues there and link them to and issue like this one properly.

If you’d like to know how the “roll your own” attitude get’s you into a maintainance night mare just look how Wikimedia has it’s own environment for everything Wikipedia related. For small organization like yours or the Wikimedia foundation it IMHO makes no sense to go this route.

hurts-my


Lat Lon are always decimal and not string as you can see from several links:

  1. In Blog: Easily build location-aware apps
  2. In Documentation: Representing geolocation data
  3. In Discuss: RFC for implementing GEO features in GraphQL

And decimal is universally accepted:

  1. How many decimal digits to store Lat Lon?
  2. GeoJSON format also stores location data in decimal.
  3. Google Maps uses decimal as well.

TL;DR: Store the Lat Lon in Decimal format, so that both client & server can prevent unnecessary type casting.

does not make any sense what so ever if the issue is about coordinates to have to be float. The message is IMHO not helpful at all and should be fixed.