ALIYUN::MaxCompute::Table类型用于创建表。

语法

{
  "Type": "ALIYUN::MaxCompute::Table",
  "Properties": {
    "Comment": String,
    "Project": String,
    "IfNotExists": Boolean,
    "Lifecycle": Number,
    "Schema": Map,
    "StringSchema": String,
    "Name": String
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
Comment String 表注释内容。
Project String 项目名称。 如果不指定该参数,将使用默认项目。
IfNotExists Boolean 存在同名表时是否报错。 如果不指定该参数,当存在同名表时,会报错。

如果指定该参数,无论是否存在同名表,均返回成功。已存在的同名表的元数据信息不会被改动。

Lifecycle Number 表的生命周期。
Schema Map 表模式。 更多信息,请参见Schema属性
StringSchema String 创建一个包含字段名称和字段类型字符串的表。
Name String 表名称。 长度为1~128个字符,可包含英文字母、数字和下划线(_)。

Schema语法

"Schema": {
  "Partitions": List,
  "Columns": List
}

Schema属性

属性名称 类型 必须 允许更新 描述 约束
Partitions List 分区。 更多信息,请参见Partitions属性
Columns List 列。 更多信息,请参见Columns属性

Partitions语法

"Partitions": [
  {
    "Comment": String,
    "Type": String,
    "Name": String
  }
]

Partitions属性

属性名称 类型 必须 允许更新 描述 约束
Comment String 分区注释。
Type String 分区类型。
Name String 分区名称。

Columns语法

"Columns": [
  {
    "Comment": String,
    "Type": String,
    "Name": String
  }
]

Columns属性

属性名称 类型 必须 允许更新 描述 约束
Comment String 列注释。
Type String 列类型。
Name String 列名称。

返回值

Fn::GetAtt

  • Project:项目名称。
  • Name:表名。

示例

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "Comment": {
      "Type": "String",
      "Description": "Table comment"
    },
    "Project": {
      "Type": "String",
      "Description": "Project name, if not provided, will be the default project"
    },
    "IfNotExists": {
      "Type": "Boolean",
      "Description": "If you create a table by using the name of an existing table and \nthe parameter set to false, an error is returned. \nIf you specify the if not exists parameter, a success message \nis returned when you create a table by using the name of an \nexisting table. The success message is returned even if the \nschema of the existing table is different from that of the table you want to create. \nIf you create a table by using the name of an existing table, \nthe table is not created and the metadata of the existing table is not changed.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ]
    },
    "Lifecycle": {
      "Type": "Number",
      "Description": "Table's lifecycle."
    },
    "Schema": {
      "Type": "Json",
      "Description": "Table schema"
    },
    "StringSchema": {
      "Type": "String",
      "Description": "Create a table with field names and field type strings.\nExample: 'num bigint, num2 double', 'pt string'"
    },
    "Name": {
      "Type": "String",
      "Description": "Table name",
      "AllowedPattern": "[A-Za-z0-9_]{1,128}"
    }
  },
  "Resources": {
    "Table": {
      "Type": "ALIYUN::MaxCompute::Table",
      "Properties": {
        "Comment": {
          "Ref": "Comment"
        },
        "Project": {
          "Ref": "Project"
        },
        "IfNotExists": {
          "Ref": "IfNotExists"
        },
        "Lifecycle": {
          "Ref": "Lifecycle"
        },
        "Schema": {
          "Ref": "Schema"
        },
        "StringSchema": {
          "Ref": "StringSchema"
        },
        "Name": {
          "Ref": "Name"
        }
      }
    }
  },
  "Outputs": {
    "Project": {
      "Description": "Project name",
      "Value": {
        "Fn::GetAtt": [
          "Table",
          "Project"
        ]
      }
    },
    "Name": {
      "Description": "Table name",
      "Value": {
        "Fn::GetAtt": [
          "Table",
          "Name"
        ]
      }
    }
  }
}

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  Comment:
    Description: Table comment
    Type: String
  IfNotExists:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Description: "If you create a table by using the name of an existing table and\
      \ \nthe parameter set to false, an error is returned. \nIf you specify the if\
      \ not exists parameter, a success message \nis returned when you create a table\
      \ by using the name of an \nexisting table. The success message is returned\
      \ even if the \nschema of the existing table is different from that of the table\
      \ you want to create. \nIf you create a table by using the name of an existing\
      \ table, \nthe table is not created and the metadata of the existing table is\
      \ not changed."
    Type: Boolean
  Lifecycle:
    Description: Table's lifecycle.
    Type: Number
  Name:
    AllowedPattern: '[A-Za-z0-9_]{1,128}'
    Description: Table name
    Type: String
  Project:
    Description: Project name, if not provided, will be the default project
    Type: String
  Schema:
    Description: Table schema
    Type: Json
  StringSchema:
    Description: 'Create a table with field names and field type strings.

      Example: ''num bigint, num2 double'', ''pt string'''
    Type: String
Resources:
  Table:
    Properties:
      Comment:
        Ref: Comment
      IfNotExists:
        Ref: IfNotExists
      Lifecycle:
        Ref: Lifecycle
      Name:
        Ref: Name
      Project:
        Ref: Project
      Schema:
        Ref: Schema
      StringSchema:
        Ref: StringSchema
    Type: ALIYUN::MaxCompute::Table
Outputs:
  Name:
    Description: Table name
    Value:
      Fn::GetAtt:
      - Table
      - Name
  Project:
    Description: Project name
    Value:
      Fn::GetAtt:
      - Table
      - Project