[Python] How to handle optional/null fields when inserting rows into TimeSeries container?

Discussão em 'Python' iniciado por Stack, Junho 20, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using the griddb_python client to insert sensor data into a TimeSeries container in GridDB Cloud. The data comes from various IoT devices, and not all fields are always present in the payload.

    Here’s an example of my payload:

    {
    "device_id": "sensor_A23",
    "timestamp": "2025-06-12T10:00:00Z",
    "temperature": 26.7,
    "humidity": null
    }



    Container schema:

    store.put_container("iot_data", [
    ("timestamp", griddb.Type.TIMESTAMP),
    ("device_id", griddb.Type.STRING),
    ("temperature", griddb.Type.FLOAT),
    ("humidity", griddb.Type.FLOAT)
    ], griddb.ContainerType.TIME_SERIES, True)



    I’m trying to insert this row using:

    container.put_row([
    timestamp, device_id, temperature, humidity # humidity is None
    ])



    But this raises an error:

    griddb.gsexception.GSException: [ILLEGAL_PARAMETER(0x0123)] NULL is not allowed for column (Column index = 3)



    Question:

    Does GridDB support NULL/None values for numeric types in TimeSeries containers? If not, how should I handle missing sensor fields without using placeholder values like -999?

    What I’ve tried:


    • Tried omitting the field from the row — raises an argument count mismatch error.


    • I checked the griddb_python GitHub repo and docs but no mention of how nullability works for numeric columns.


    • Replacing None with float('nan')—this is accepted, but it’s unclear if GridDB treats NaN as a valid missing value example for aggregates like AVG, SUM.

    Continue reading...

Compartilhe esta Página