IoT Core Rule SQL - Why doesn't the AWS IoT SQL WHERE clause work with many fields when using the OR operator?

0

ex: I have a SQL query: select * from 'iot/+/noti' where a = 0 OR b = 0 OR c = 0

  • when i publish { "timestamp": 123, "a": 0} => OK, i see iot log { "timestamp": 123, "a": 0}
  • when i publish { "timestamp": 123, "b": 0} => NG, i don't see iot log
  • when i publish { "timestamp": 123, "c": 0} => NG, i don't see iot log

Please help me ! Where is the error in my SQL statement ? Note: SQL version: 2016-03-23

preguntada hace 8 meses268 visualizaciones
1 Respuesta
2
Respuesta aceptada

Hi. The problem is that the missing values will be Undefined and not evaluate as Boolean: https://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-operators.html#iot-sql-operators-or

Try this:

select * from 'iot/+/noti' where (isUndefined(a) = False AND a = 0) OR (isUndefined(b) = False AND b = 0) OR (isUndefined(c) = False AND c = 0)
profile pictureAWS
EXPERTO
Greg_B
respondido hace 8 meses
profile picture
EXPERTO
revisado hace 8 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas