SQL versions - Amazon IoT Core
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

SQL versions

The Amazon IoT rules engine uses an SQL-like syntax to select data from MQTT messages. The SQL statements are interpreted based on an SQL version specified with the awsIotSqlVersion property in a JSON document that describes the rule. For more information about the structure of JSON rule documents, see Creating a Rule. The awsIotSqlVersion property lets you specify which version of the Amazon IoT SQL rules engine that you want to use. When a new version is deployed, you can continue to use an earlier version or change your rule to use the new version. Your current rules continue to use the version with which they were created.

The following JSON example shows you how to specify the SQL version using the awsIotSqlVersion property.

{ "sql": "expression", "ruleDisabled": false, "awsIotSqlVersion": "2016-03-23", "actions": [{ "republish": { "topic": "my-mqtt-topic", "roleArn": "arn:aws:iam::123456789012:role/my-iot-role" } }] }

Amazon IoT currently supports the following SQL versions:

  • 2016-03-23 – The SQL version built on 2016-03-23 (recommended).

  • 2015-10-08 – The original SQL version built on 2015-10-08.

  • beta – The most recent beta SQL version. This version could introduce breaking changes to your rules.

What's new in the 2016-03-23 SQL rules engine version

  • Fixes for selecting nested JSON objects.

  • Fixes for array queries.

  • Intra-object query support. For more information, see Nested object queries.

  • Support to output an array as a top-level object.

  • Addition of the encode(value, encodingScheme) function, which can be applied on JSON and non-JSON format data. For more information, see the encode function.

Output an Array as a top-level object

This feature allows a rule to return an array as a top-level object. For example, given the following MQTT message:

{ "a": {"b":"c"}, "arr":[1,2,3,4] }

And the following rule:


The rule generates the following output.