Reputation: 21
Just wondering if anyone has worked out how to store null values in a timestream database:
I have the following code:
dimensions = [
{'Name': 'gatewayId', 'Value': gatewayId}
]
connectedDays = {
'Dimensions': dimensions,
'MeasureName': 'connectedDays',
'MeasureValue': str(data[3]),
'MeasureValueType': 'BIGINT',
'Time': current_time
}
Either gatewayId or data[3] could be any empty strings and would need storing a nulls in the DB but I am not sure how to do this. I've tried passing all sorts like None (etc) but AWS timestream complains every time.
I am using python.
Its so new the documentation doesn't even cover it.
Thanks
Upvotes: 2
Views: 1628
Reputation: 9716
In kotlin we can do some filtering to make it work:
val dimensions = listOf(
Dimension.builder().name("principal").value(auditLogData.principal).build(),
if (auditLogData.customerAccount.isNotEmpty()) Dimension.builder().name("customerAccount").value(auditLogData.customerAccount).build() else null,
if (auditLogData.resourceId.isNotEmpty()) Dimension.builder().name("resourceId").value(auditLogData.resourceId).build() else null
).filterNotNull()
This removes empty dimensions before doing the write request.
As long as the dimensions are not there instead of being null it is possible to do a write request.
Upvotes: 2