I’m executing an aggregation query against a GridDB collection and converting the returned value directly to an integer. The query succeeds, but the conversion fails when the aggregation result is returned as a floating-point value.
import griddb_python as griddb
factory = griddb.StoreFactory.get_instance()
store = factory.get_store(
notification_member="127.0.0.1:10001",
cluster_name="myCluster",
username="admin",
password="admin"
)
container = store.get_container("sensor_data")
query = container.query(
"SELECT device_id, AVG(temperature) "
"WHERE device_id = 'sensor-01' "
"GROUP BY device_id"
)
rs = query.fetch()
while rs.has_next():
row = rs.next()
average = int(row[1])
print(average)
For the following data:
sensor-01, 20.5
sensor-01, 21.5
I receive:
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
The query itself executes successfully, but row\[1\] is None for some groups.
Environment:
GridDB Server: 5.9 CE
GridDB Python Client: 0.9.x
Python: 3.12.x
OS: Ubuntu 22.04 LTS
Why can an aggregation result be NULL for a group containing numeric values, and what is the recommended way to handle aggregation results returned by the Python client?