【问题标题】:AWS Timestream DB - storing null values - PythonAWS Timestream DB - 存储空值 - Python
【发布时间】:2021-02-22 14:49:21
【问题描述】:

只是想知道是否有人研究出如何在时间流数据库中存储空值:

我有以下代码:

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

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

gatewayId 或 data[3] 都可以是任何空字符串,并且需要在数据库中存储空值,但我不确定如何执行此操作。我试过通过各种方式,比如无(等),但 AWS 时间流每次都会抱怨。

我正在使用 python。

它太新了,文档甚至都没有涵盖它。

谢谢

【问题讨论】:

    标签: amazon-timestream


    【解决方案1】:

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

    这会在执行写入请求之前删除空白维度。

    只要维度不存在而不是为空,就可以进行写入请求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-04
      • 2021-06-04
      • 2021-01-20
      • 2021-07-14
      • 2021-12-25
      • 1970-01-01
      • 2022-08-03
      • 2019-04-10
      相关资源
      最近更新 更多