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

demandé il y a 8 mois268 vues
1 réponse
2
Réponse acceptée

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
EXPERT
Greg_B
répondu il y a 8 mois
profile picture
EXPERT
vérifié il y a 8 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions