AWS Timestream DB-存储空值-Python

问题描述

只是想知道是否有人解决了如何在时间流数据库中存储空值的问题:

我有以下代码

                dimensions = [ 
                   {'Name': 'gatewayId','Value': gatewayId}                   
                  ]

                 connectedDays = { 
                   'Dimensions': dimensions,'MeasureName': 'connectedDays','MeasureValue': str(data[3]),'MeasureValueType': 'BIGINT','Time': current_time 
                    }

gatewayId或data [3]可以是任何空字符串,并且需要在数据库中存储null,但是我不确定如何执行此操作。我已经尝试过传递诸如None(等等)之类的各种消息,但是AWS时间流每次都会抱怨。

我正在使用python。

它是如此新,文档甚至都没有涵盖它。

谢谢

解决方法

在kotlin中,我们可以进行一些过滤以使其起作用:

    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()

这会在执行写请求之前删除空白尺寸。

只要尺寸不存在(而不是null),就可以发出写请求。