Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

286
Visualizações
How to force AWS Timestream to always interpret a number as double in an IoTCore rule?

Sensor payload decoders are mostly provided as javascript code by the sensor manufacturers. As I'm using different sensor types, I want to use the original decoders without rewriting them in other languages. So I'm using an AWS Lambda (NodeJS) within AWS IoTCore rules for decoding the different sensor payloads, which works fine.

In a succeeding IoTCore rule, I want to send the decoded sensor payload to an AWS Timestream database. AWS Timestream data types are fixed during the first write. So, if the first measurement value "temperature" was a float number like 23.14 degree, the measurement type is fixed to a Timestream::Double type, which is what I want.

However, if the sensor measures a value of a flat 23.0 degrees the next time, then the Timestream write operation leads to the error "Measure name already has an assigned measure value type. Each measure name can have only one measure value type and cannot be changed."

The reason lies in the AWS Timestream parser, which works like so: A numeric value without a decimal point is interpreted as a BigInt type. So,...

> const f1 = 23.4
> const f2 = 23.0
> console.log(f1, typeof f1, f2, typeof f2)
 23.4 'number' 23 'number'
parseFloat(23.14) // becomes Javascript::Number 23.14 Timestream::Double. ==> ok!
parseFloat(23.00) // becomes Javascript::Number 23    Timestream::BigInt  ==> Error! 

I don't want to use parseFloat(23.00).toFixed(2) as it becomes a string value, nor parseFloat(23.00) + 0.001 as it is changing the value and requires always converting/rounding values when processing the AWS Timestream values later on.

How to solve that?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Solved by skipping the IoTCore rule framework and writing in Lambda directly to Timestream, there I can explicitly set the measureValueType = "DOUBLE" , which avoids that kind of problem.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda