Query Name and Version

Syntax

CREATE [STREAM | CHANGELOG] relation_name
...
AS select_statement ...
QUERY WITH('query.name' = query_name);

Description

Queries can be launched with an optional name by specifying the query.name property in the QUERY WITH block. This allows queries to be referred to by name in other commands like DESCRIBE QUERY and TERMINATE QUERY.

Query name must not conflict with the names of any other running queries within the Organization. However, it may reuse the name of a previously terminated query. Doing so will lauch the new query with the same name.

Each query is also assigned a version number. The first query to use a particular name is assigned version 1. The next query to reuse the name will get version 2 and so on.

The LIST QUERIES can be used to view the query name and version of running or terminated queries.

Arguments

query.name

This specifies the unique query name to use when launching a query.

Examples

Launch a named query

The following is an example of how to launch a Query with a name. Note the Name from LIST QUERIES is the same as the query.name.

demodb.public/demostore# CREATE STREAM demostream AS SELECT * FROM pageviews QUERY WITH('query.name' = demoquery);
+--------+--------------------------------------+----------+---------------------------------------------------------------------+
|  Type  |                 Name                 |  Command |                               Summary                               |
+--------+--------------------------------------+----------+---------------------------------------------------------------------+
| stream | demodb.public.demostream             | CREATE   | stream "demostream" was successfully created                        |
+--------+--------------------------------------+----------+---------------------------------------------------------------------+
| query  | 89f21634-39a0-44e4-979d-9f35017a8ca0 | CREATE   | query 89f21634-39a0-44e4-979d-9f35017a8ca0 was successfully created |
+--------+--------------------------------------+----------+---------------------------------------------------------------------+

demodb.public/demostore# LIST QUERIES;
+--------------------------------------+-----------+----------+-----------------+---------------+-------------------------------------------------------------------------------------------+----------+-------------------------------+-------------------------------+
|                  ID                  |    Name   |  Version |  Intended State |  Actual State |                                                           Query                           |   Owner  |           Created At          |           Updated At          |
+--------------------------------------+-----------+----------+-----------------+---------------+-------------------------------------------------------------------------------------------+----------+-------------------------------+-------------------------------+
| 89f21634-39a0-44e4-979d-9f35017a8ca0 | demoquery |        1 | running         | new           | CREATE STREAM demostream AS SELECT * FROM pageviews QUERY WITH('query.name' = demoquery); | sysadmin | 2024-07-30 20:00:01 +0000 UTC | 2024-07-30 20:00:05 +0000 UTC |
+--------------------------------------+-----------+----------+-----------------+---------------+-------------------------------------------------------------------------------------------+----------+-------------------------------+-------------------------------+

Last updated