Table

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

Bases: S3Table

(deprecated) A Glue table.

Deprecated:

Use {@link S3Table } instead.

Stability:

deprecated

ExampleMetadata:

infused

Example:

# glue_database: glue.IDatabase

table = glue.Table(self, "Table",
    storage_parameters=[
        glue.StorageParameter.skip_header_line_count(1),
        glue.StorageParameter.compression_type(glue.CompressionType.GZIP),
        glue.StorageParameter.custom("foo", "bar"),  # Will have no effect
        glue.StorageParameter.custom("separatorChar", ","),  # Will describe the separator char used in the data
        glue.StorageParameter.custom(glue.StorageParameters.WRITE_PARALLEL, "off")
    ],
    # ...
    database=glue_database,
    columns=[glue.Column(
        name="col1",
        type=glue.Schema.STRING
    )],
    data_format=glue.DataFormat.CSV
)
Parameters:
  • scope (Construct) –

  • id (str) –

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

  • 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: BucketEncryption.S3_MANAGED

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

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

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

  • 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

  • enable_partition_filtering (Optional[bool]) – (experimental) Enables partition filtering. Default: - The parameter is not defined

  • parameters (Optional[Mapping[str, str]]) – (experimental) The key/value pairs define properties associated with the table. The key/value pairs that are allowed to be submitted are not limited, however their functionality is not guaranteed. Default: - The parameter is not defined

  • 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

  • storage_parameters (Optional[Sequence[StorageParameter]]) – (experimental) The user-supplied properties for the description of the physical storage of this table. These properties help describe the format of the data that is stored within the crawled data sources. The key/value pairs that are allowed to be submitted are not limited, however their functionality is not guaranteed. Some keys will be auto-populated by glue crawlers, however, you can override them by specifying the key and value in this property. Default: - The parameter is not defined

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

  • table_name (Optional[str]) – (experimental) Name of the table. Default: - generated by CDK.

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 tree node.

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.

storage_parameters

(experimental) The tables’ storage descriptor properties.

Stability:

experimental

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)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool