The Execute KSQL Command action is available from KSQL object viewlets. KSQL objects can be set up when on the KSQL tab when you create a Remote Kafka Manager Connection.
The example below shows KSQL commands being used to create a table and a stream. To learn how to view the table and stream records, see Read Queries, Tables, and Streams.
Execute a KSQL Command
To execute a KSQL command:
- On a KSQL viewlet, click Execute KSQL Command on a KSQL object's action menu (Selected menu in 11.2). The Kafka KSQL Commands dialog opens.
- Enter the SQL Command in the SQL field.
- Click OK. The result of the command is displayed in the Response field.
Create Table Command
CREATE TABLE TABLE1 (
id BIGINT PRIMARY KEY,
usertimestamp BIGINT,
region_id VARCHAR
) WITH (
KAFKA_TOPIC = 'ksql_topic2',
VALUE_FORMAT = 'JSON'
);
Create Stream Command
CREATE STREAM KSQL2 (
ksqlq_id BIGINT,
time BIGINT,
user_id VARCHAR
) WITH (
KAFKA_TOPIC = 'ksql_topic2',
VALUE_FORMAT = 'JSON'
);