更新时间:2022-12-07 GMT+08:00

描述表信息

功能介绍

该API用于描述指定表的元数据信息。

URI

  • URI格式:

    GET /v1.0/{project_id}/databases/{database_name}/tables/{table_name}

  • 参数说明
    表1 URI 参数

    参数名称

    是否必选

    参数类型

    说明

    project_id

    String

    项目编号,用于资源隔离。获取方式请参考获取项目ID

    database_name

    String

    待描述的表所在的数据库名称。

    table_name

    String

    待描述表的名称。

请求消息

无请求参数。

响应消息

表2 响应参数

参数名称

是否必选

参数类型

说明

is_success

Boolean

执行请求是否成功。“true”表示请求执行成功。

message

String

系统提示信息,执行成功时,信息可能为空。

column_count

Integer

表的总列数。

columns

Array of Objects

表的列信息,包含列名称、类型和描述信息。具体参数详见表3

table_type

String

表类型,包括:

“MANAGED”:DLI表。

“EXTERNAL”:OBS表。

“VIEW”:VIEW视图。

data_type

String

数据类型,包括“csv”,“parquet”,“orc”,“json”和“avro”。

data_location

String

数据存储的路径,为OBS路径。

storage_properties

Array of Objects

存储属性,以“key/value”的格式出现,包含delimiter,escape,quote,header,dateformat,timestampformat参数。

table_comment

String

表的注释。

create_table_sql

String

该表的建表语句。

表3 columns参数

参数名称

是否必选

参数类型

说明

column_name

String

列名称。

description

String

列描述信息。

type

String

列数据类型。

is_partition_column

Boolean

表示该列是否为分区列,“true”表示为分区列,“false”为非分区列,默认为“false”

请求示例

响应示例

  • MANAGED类型表
    {
      "is_success": true,
      "message": "",
      "column_count": 3,
      "columns": [
        {
          "column_name": "id",
          "description": "",
          "type": "int",
          "is_partition_column": false
        },
        {
          "column_name": "name",
          "description": "",
          "type": "string",
          "is_partition_column": false
        },
        {
          "column_name": "level",
          "description": "",
          "type": "string",
          "is_partition_column": true
        }
      ],
        "table_type":"MANAGED"
    }
  • EXTERNAL类型表
    {
        "is_success": true,
        "message": "",
        "column_count": 2,
        "columns": [
            {
                "type": "string",
                "description": "",
                "column_name": "col2",
                "is_partition_column": false
            },
            {
                "type": "string",
                "description": "",
                "column_name": "col1",
                "is_partition_column": true
            }
        ],
        "table_type": "EXTERNAL",
        "data_type": "parquet",
        "data_location": "obs://obs-wangtao/savepoint/savepoint-d95437-039668840fff/_metadata",
        "storage_properties": [
            {
                "key": "timestampformat",
                "value": "yyyy-MM-dd HH:mm:ss"
            },
            {
                "key": "quote",
                "value": "\""
            },
            {
                "key": "dateformat",
                "value": "yyyy-MM-dd"
            },
            {
                "key": "escape",
                "value": "\\"
            },
            {
                "key": "header",
                "value": "false"
            },
            {
                "key": "delimiter",
                "value": ","
            }
        ],
        "table_comment": "",
         "create_table_sql": "CREATE TABLE `default`.`wan_test` (`col2` STRING, `col1` STRING)\nUSING parquet\nOPTIONS (\n  `timestampformat` 'yyyy-MM-dd HH:mm:ss',\n  `quote` '\"',\n  `dateformat` 'yyyy-MM-dd',\n  `escape` '\\\\',\n  `header` 'false',\n  `delimiter` ','\n)\nPARTITIONED BY (col1)\nCOMMENT ''\nLOCATION 'obs://obs-wangtao/savepoint/savepoint-d95437-039668840fff/_metadata'\nTBLPROPERTIES (\n  'hive.serialization.extend.nesting.levels' = 'true'\n)\n"
       }
  • VIEW类型表
    {
      "is_success": true,
      "message": "",
      "column_count": 3,
      "columns": [
        {
          "column_name": "id",
          "description": "",
          "type": "int",
          "is_partition_column": false
        },
        {
          "column_name": "name",
          "description": "",
          "type": "string",
          "is_partition_column": false
        },
        {
          "column_name": "level",
          "description": "",
          "type": "string",
          "is_partition_column": true
        }
      ],
      "table_type":"VIEW",
      "create_table_sql": "CREATE VIEW `default`.`view1`(id, name) AS\nselect * from a_gff.testtable\n"
    }

状态码

状态码如表4所示。

表4 状态码

状态码

描述

200

操作成功。

400

请求错误。

500

内部服务器错误。

错误码

调用接口出错后,将不会返回上述结果,而是返回错误码和错误信息,更多介绍请参见错误码