Tables management
The eKuiper REST api for tables allows you to manage the tables, such as create, describe, show and drop table definitions.
create a table
The API is used for creating a table. For more detailed information of table definition, please refer to tables.
POST http://localhost:9081/tables
Request sample, the request is a json string with sql
field.
{"sql":"create table my_table (id bigint, name string, score float) WITH ( datasource = \"lookup.json\", FORMAT = \"json\", KEY = \"id\")"}
This API can run any table sql statements, not only table creation.
show tables
The API is used for displaying all of tables defined in the server.
GET http://localhost:9081/tables
Response Sample:
["mytable"]
This API accepts one parameter kind, the value could be scan
or lookup
to query each kind of tables. Other values are invalid, it will return all kinds of tables. In below example, we can query all the lookup tables.
GET http://localhost:9081/tables?kind=lookup
show tables detail
The API is used for displaying all detailed definition of tables defined in the server.
GET http://localhost:9081/tabledetails
Response Sample:
[
{
"name": "test2",
"type": "file",
"format": "json"
}
]
This API accepts one parameter kind, the value could be scan
or lookup
to query each kind of tables. Other values are invalid, it will return all kinds of tables. In below example, we can query all the lookup tables.
GET http://localhost:9081/tabledetails?kind=lookup
describe a table
The API is used for print the detailed definition of table.
GET http://localhost:9081/tables/{id}}
Response Sample:
{
"Name": "demo",
"StreamFields": [
{
"Name": "temperature",
"FieldType": {
"Type": 2
}
},
{
"Name": "ts",
"FieldType": {
"Type": 1
}
}
],
"Options": {
"DATASOURCE": "lookup.json",
"FORMAT": "JSON"
}
}
Get table schema
The API is used to get the table schema. The schema is inferred from the physical and logical schema definitions.
GET http://localhost:9081/tables/{id}/schema
update a table
The API is used for update the table definition.
PUT http://localhost:9081/tables/{id}
Path parameter id
is the id or name of the old table.
Request sample, the request is a json string with sql
field.
{"sql":"create table my_table (id bigint, name string, score float) WITH ( datasource = \"topic/temperature\", FORMAT = \"json\", KEY = \"id\")"}
drop a table
The API is used for drop the table definition.
DELETE http://localhost:9081/tables/{id}