Query Schema Action
Requestβ
POST /api/query_schema/<ns_name>/<db_name>
Descriptionβ
The Query Schema Action can return the table creation statement for the given SQL-related table. Can be used to test some query scenarios locally.
The API was released in version 1.2.
Path parametersβ
-
<db_name>
Specify the database name. This database will be considered as the default database for the current session, and will be used if the table name in SQL does not qualify the database name.
Query parametersβ
None
Request bodyβ
text/plain
sql
- "sql" field is the SQL string.
Responseβ
-
Return value
CREATE TABLE `tbl1` (
`k1` int(11) NULL,
`k2` int(11) NULL
) ENGINE=OLAP
DUPLICATE KEY(`k1`, `k2`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`k1`) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2",
"disable_auto_compaction" = "false"
);
CREATE TABLE `tbl2` (
`k1` int(11) NULL,
`k2` int(11) NULL
) ENGINE=OLAP
DUPLICATE KEY(`k1`, `k2`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`k1`) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2",
"disable_auto_compaction" = "false"
);
Exampleβ
-
Write the SQL in local file 1.sql
select tbl1.k2 from tbl1 join tbl2 on tbl1.k1 = tbl2.k1;
-
Use curl to get the table creation statement.
curl -X POST -H 'Content-Type: text/plain' -uroot: http://127.0.0.1:8030/api/query_schema/internal/db1 -d@1.sql