ALIYUN::MaxCompute::Table is used to create a table.

Syntax

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

Properties

Property Type Required Editable Description Constraint
Comment String No No The comment of the table. None
Project String Yes No The name of the project. If this parameter is not specified, the default project is used.
IfNotExists Boolean No No Specifies whether to report an error when a table with the same name already exists. If this parameter is not specified, an error is reported when a table with the same name already exists.

If this parameter is specified, no error occurs regardless of whether a table with the same name already exists. If you create a table by using the name of an existing table, the table is not created and the metadata of the existing table is not changed.

Lifecycle Number No No The lifecycle of the table. None
Schema Map No No The schema of the table. For more information, see Schema properties.
StringSchema String No No The schema used to create a table that contains string-typed field names and field types. None
Name String Yes No The name of the table. The name must be 1 to 128 characters in length and can contain letters, digits, and underscores (_).

Schema syntax

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

Schema properties

Property Type Required Editable Description Constraint
Partitions List No No The partitions of the table. For more information, see Partitions properties.
Columns List Yes No The columns of the table. For more information, see Columns properties.

Partitions syntax

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

Partitions properties

Property Type Required Editable Description Constraint
Comment String No No The comment of the partition. None
Type String Yes No The type of the partition. None
Name String Yes No The name of the partition. None

Columns syntax

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

Columns properties

Property Type Required Editable Description Constraint
Comment String No No The comment of the column. None
Type String Yes No The type of the column. None
Name String Yes No The name of the column. None

Response parameters

Fn::GetAtt

  • Project: the name of the project.
  • Name: the name of the table.

Examples

JSON format

{
  "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 format

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