ExternalTable

class aws_cdk.aws_glue_alpha.ExternalTable(scope, id, *, connection, external_data_location, 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: TableBase

(experimental) A Glue table that targets an external data location (e.g. A table in a Redshift Cluster).

Stability:

experimental

Resource:

AWS::Glue::Table

ExampleMetadata:

infused

Example:

# my_connection: glue.Connection
# my_database: glue.Database

glue.ExternalTable(self, "MyTable",
    connection=my_connection,
    external_data_location="default_db_public_example",  # A table in Redshift
    # ...
    database=my_database,
    columns=[glue.Column(
        name="col1",
        type=glue.Schema.STRING
    )],
    data_format=glue.DataFormat.JSON
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • connection (IConnection) – (experimental) The connection the table will use when performing reads and writes. Default: - No connection

  • external_data_location (str) – (experimental) The data source location of the glue table, (e.g. default_db_public_example for Redshift). If this property is set, it will override both bucket and s3Prefix. Default: - No outsourced data source location

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

Parameters:

grantee (IGrantable) – the principal.

Stability:

experimental

Return type:

Grant

grant_read_write(grantee)

(experimental) Grant read and write permissions to the table.

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.

Parameters:

grantee (IGrantable) – the principal.

Stability:

experimental

Return type:

Grant

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

columns

(experimental) This table’s columns.

Stability:

experimental

compressed

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

Stability:

experimental

connection

(experimental) The connection associated to this table.

Stability:

experimental

data_format

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

Stability:

experimental

database

(experimental) Database this table belongs to.

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

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