Streams management
The eKuiper stream command line tools allows you to manage the streams, such as create, describe, show and drop stream definitions.
create a stream
The command is used for creating a stream. For more detailed information of stream definition, please refer to streams.
create stream $stream_name '$stream_def' | create stream -f $stream_def_file- Specify the stream definition in command line.
Sample:
# bin/kuiper create stream my_stream '(id bigint, name string, score float) WITH ( datasource = "topic/temperature", FORMAT = "json", KEY = "id")'
stream my_stream createdThe command create a stream named my_stream.
- Specify the stream definition in file. If the stream is complex, or the stream is already wrote in text files with well organized formats, you can just specify the stream definition through
-foption.
Sample:
# bin/kuiper create stream -f /tmp/my_stream.txt
stream my_stream createdBelow is the contents of my_stream.txt.
my_stream(id bigint, name string, score float)
WITH ( datasource = "topic/temperature", FORMAT = "json", KEY = "id");show streams
The command is used for displaying all of streams defined in the server.
show streamsSample:
# bin/kuiper show streams
my_streamdescribe a stream
The command is used for print the detailed definition of stream.
describe stream $stream_name | describe stream $stream_name -jsonSample:
# bin/kuiper describe stream my_stream
Fields
--------------------------------------------------------------------------------
id bigint
name string
score float
FORMAT: json
KEY: id
DATASOURCE: topic/temperatureYou can also use the -json option to get json formatted output.
Sample:
# bin/kuiper describe stream my_stream -json
'{
"Fields": [
{
"Name": "id",
"Type": "bigint"
},
{
"Name": "name",
"Type": "string"
},
{
"Name": "score",
"Type": "float"
}
],
"Options": {
"DATASOURCE:": "topic/temperature",
"FORMAT:": "json",
"KEY:": "id"
}
}'drop a stream
The command is used for drop the stream definition.
drop stream $stream_nameSample:
# bin/kuiper drop stream my_stream
stream my_stream droppedquery against streams
The command is used for querying data from stream.
querySample:
# bin/kuiper query
kuiper >After typing query sub-command, it prompts kuiper >, then type SQLs (see eKuiper SQL reference for how to use eKuiper SQL) in the command prompt and press enter.
The results will be print in the console.
kuiper > SELECT * FROM my_stream WHERE id > 10;
[{"...":"..." ....}]
...Press
CTRL + Cto stop the query;If no SQL are type, you can type
quitorexitto quit thekuiperprompt console.