Query Schema Action

Request

  1. 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

  1. text/plain
  2. sql
  • “sql” field is the SQL string.

Response

  • Return value

    1. CREATE TABLE `tbl1` (
    2. `k1` int(11) NULL,
    3. `k2` int(11) NULL
    4. ) ENGINE=OLAP
    5. DUPLICATE KEY(`k1`, `k2`)
    6. COMMENT 'OLAP'
    7. DISTRIBUTED BY HASH(`k1`) BUCKETS 3
    8. PROPERTIES (
    9. "replication_allocation" = "tag.location.default: 1",
    10. "in_memory" = "false",
    11. "storage_format" = "V2",
    12. "disable_auto_compaction" = "false"
    13. );
    14. CREATE TABLE `tbl2` (
    15. `k1` int(11) NULL,
    16. `k2` int(11) NULL
    17. ) ENGINE=OLAP
    18. DUPLICATE KEY(`k1`, `k2`)
    19. COMMENT 'OLAP'
    20. DISTRIBUTED BY HASH(`k1`) BUCKETS 3
    21. PROPERTIES (
    22. "replication_allocation" = "tag.location.default: 1",
    23. "in_memory" = "false",
    24. "storage_format" = "V2",
    25. "disable_auto_compaction" = "false"
    26. );

Example

  1. Write the SQL in local file 1.sql

    1. select tbl1.k2 from tbl1 join tbl2 on tbl1.k1 = tbl2.k1;
  2. Use curl to get the table creation statement.

    1. curl -X POST -H 'Content-Type: text/plain' -uroot: http://127.0.0.1:8030/api/query_schema/internal/db1 -d@1.sql