Table

class aws_cdk.aws_glue.Table(scope, id, *, columns, database, data_format, table_name, bucket=None, compressed=None, description=None, encryption=None, encryption_key=None, partition_indexes=None, partition_keys=None, s3_prefix=None, stored_as_sub_directories=None)

Bases: Resource

(experimental) A Glue table.

Stability:

experimental

ExampleMetadata:

infused

Example:

# my_database: glue.Database

glue.Table(self, "MyTable",
    database=my_database,
    table_name="my_table",
    columns=[glue.Column(
        name="col1",
        type=glue.Schema.STRING
    )],
    partition_keys=[glue.Column(
        name="year",
        type=glue.Schema.SMALL_INT
    ), glue.Column(
        name="month",
        type=glue.Schema.SMALL_INT
    )],
    data_format=glue.DataFormat.JSON
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • columns (Sequence[Union[Column, Dict[str, Any]]]) – (experimental) Columns of the table.

  • database (IDatabase) – (experimental) Database in which to store the table.

  • data_format (DataFormat) – (experimental) Storage type of the table’s data.

  • table_name (str) – (experimental) Name of the table.

  • bucket (Optional[IBucket]) – (experimental) S3 bucket in which to store data. Default: one is created for you

  • compressed (Optional[bool]) – (experimental) Indicates whether the table’s data is compressed or not. Default: false

  • description (Optional[str]) – (experimental) Description of the table. Default: generated

  • encryption (Optional[TableEncryption]) – (experimental) The kind of encryption to secure the data with. You can only provide this option if you are not explicitly passing in a bucket. If you choose SSE-KMS, you can provide an un-managed KMS key with encryptionKey. If you choose CSE-KMS, you must provide an un-managed KMS key with encryptionKey. Default: Unencrypted

  • encryption_key (Optional[IKey]) – (experimental) External KMS key to use for bucket encryption. The encryption property must be SSE-KMS or CSE-KMS. Default: key is managed by KMS.

  • partition_indexes (Optional[Sequence[Union[PartitionIndex, Dict[str, Any]]]]) – (experimental) Partition indexes on the table. A maximum of 3 indexes are allowed on a table. Keys in the index must be part of the table’s partition keys. Default: table has no partition indexes

  • partition_keys (Optional[Sequence[Union[Column, Dict[str, Any]]]]) – (experimental) Partition columns of the table. Default: table is not partitioned

  • s3_prefix (Optional[str]) – (experimental) S3 prefix under which table objects are stored. Default: - No prefix. The data will be stored under the root of the bucket.

  • stored_as_sub_directories (Optional[bool]) – (experimental) Indicates whether the table data is stored in subdirectories. Default: false

Stability:

experimental

Methods

add_partition_index(*, key_names, index_name=None)

(experimental) Add a partition index to the table.

You can have a maximum of 3 partition indexes to a table. Partition index keys must be a subset of the table’s partition keys.

Parameters:
  • key_names (Sequence[str]) – (experimental) The partition key names that comprise the partition index. The names must correspond to a name in the table’s partition keys.

  • index_name (Optional[str]) – (experimental) The name of the partition index. Default: - a name will be generated for you.

See:

https://docs.aws.amazon.com/glue/latest/dg/partition-indexes.html

Stability:

experimental

Return type:

None

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

grant(grantee, actions)

(experimental) Grant the given identity custom permissions.

Parameters:
  • grantee (IGrantable) –

  • actions (Sequence[str]) –

Stability:

experimental

Return type:

Grant

grant_read(grantee)

(experimental) Grant read permissions to the table and the underlying data stored in S3 to an IAM principal.

Parameters:

grantee (IGrantable) – the principal.

Stability:

experimental

Return type:

Grant

grant_read_write(grantee)

(experimental) Grant read and write permissions to the table and the underlying data stored in S3 to an IAM principal.

Parameters:

grantee (IGrantable) – the principal.

Stability:

experimental

Return type:

Grant

grant_to_underlying_resources(grantee, actions)

(experimental) Grant the given identity custom permissions to ALL underlying resources of the table.

Permissions will be granted to the catalog, the database, and the table.

Parameters:
  • grantee (IGrantable) –

  • actions (Sequence[str]) –

Stability:

experimental

Return type:

Grant

grant_write(grantee)

(experimental) Grant write permissions to the table and the underlying data stored in S3 to an IAM principal.

Parameters:

grantee (IGrantable) – the principal.

Stability:

experimental

Return type:

Grant

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

bucket

(experimental) S3 bucket in which the table’s data resides.

Stability:

experimental

columns

(experimental) This table’s columns.

Stability:

experimental

compressed

(experimental) Indicates whether the table’s data is compressed or not.

Stability:

experimental

data_format

(experimental) Format of this table’s data files.

Stability:

experimental

database

(experimental) Database this table belongs to.

Stability:

experimental

encryption

(experimental) The type of encryption enabled for the table.

Stability:

experimental

encryption_key

(experimental) The KMS key used to secure the data if encryption is set to CSE-KMS or SSE-KMS.

Otherwise, undefined.

Stability:

experimental

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

node

The construct tree node associated with this construct.

partition_indexes

(experimental) This table’s partition indexes.

Stability:

experimental

partition_keys

(experimental) This table’s partition keys if the table is partitioned.

Stability:

experimental

s3_prefix

(experimental) S3 Key Prefix under which this table’s files are stored in S3.

Stability:

experimental

stack

The stack in which this resource is defined.

table_arn

(experimental) ARN of this table.

Stability:

experimental

table_name

(experimental) Name of this table.

Stability:

experimental

Static Methods

classmethod from_table_arn(scope, id, table_arn)
Parameters:
  • scope (Construct) –

  • id (str) –

  • table_arn (str) –

Stability:

experimental

Return type:

ITable

classmethod from_table_attributes(scope, id, *, table_arn, table_name)

(experimental) Creates a Table construct that represents an external table.

Parameters:
  • scope (Construct) – The scope creating construct (usually this).

  • id (str) – The construct’s id.

  • table_arn (str) –

  • table_name (str) –

Stability:

experimental

Return type:

ITable

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters:

x (Any) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool