I’m experimenting with GridDB CE for a project where sensor data is stored as JSON objects inside a BLOB column. For example, I have a container defined as:
ContainerInfo containerInfo = new ContainerInfo();
containerInfo.setName("SensorData");
containerInfo.setColumnInfoList(new ColumnInfo[] {
new ColumnInfo("id", GSType.STRING),
new ColumnInfo("timestamp", GSType.TIMESTAMP),
new ColumnInfo("payload", GSType.BLOB) // contains JSON
});
A typical payload JSON looks like this:
{
"temperature": 22.5,
"humidity": 60,
"location": {
"lat": 36.812,
"lon": 10.165
}
}
I’d like to query all rows where temperature > 25 AND location.lat > 35 using TQL, without having to pull all the rows into memory and parse the JSON manually.
I’ve tried something like:
SELECT * FROM SensorData WHERE payload.temperature > 25
But GridDB throws a syntax error saying the column does not exist.
Question:
Is there a way in GridDB to query JSON fields inside a BLOB column directly using TQL? If not, what’s the recommended schema design to handle this type of semi-structured data so I can still query it efficiently?