Use Links to Access Your SQL Queries

Use Spark SQL links to define queries to your different data sources and then access these queries from your analytics processors. You can create Spark SQL links by exporting an existing query from your worksheets, or create them manually.

Follow this procedure if you know exactly what to include in your SQL query. If you need to experiment with your data or with your query, see Discover Data.
  1. Go to your IoT application, select Analytics, and then select Links.
  2. Create the link:
    1. If this is your first link, click Create Link. Otherwise, click Add next to the Search field.
    2. Enter a name to identify your link.
      The name must only contain alphanumeric characters and must not contain spaces.
    3. (Optional) Enter a brief description.
    4. Click Create.
  3. From the Type list, select Spark SQL.
    The properties below the Type list change.
  4. From the Analytics Object list, select an analytics object to use to provide the result of the query.
    The field structure of this analytics object must match the structure of the rows of the table you’re querying.
  5. Enter a Spark SQL query.
  6. (Optional) Select Use from Worksheets to be able to query this link from the queries in your worksheets.
    If you select this option, then you can use this link in the from clause of your query.
    For example:
    select * from MyLink
  7. Click Save.

After you save your SQL link, you can use this link in the following ways:

  • If you add this link to your analytics processor and generate the source template, the source template will include a line of code that injects this link into your analytics processor.

  • If you selected Use from Worksheets, you can use this link in the from clause of the queries in your worksheets.

  • You can build a query on top of another query by using this link in the from clause of the queries in your worksheets.