Skip to main content
Version: 1.5.0

S3Destination

class S3Destination(
uri: str | list[str],
credentials: S3Credentials,
format: str | FileFormat = None,
region: str = None,
catalog: AWSGlue = None,
)

Bases: DestinationPlugin

Categories: destination

Class for managing the configuration of S3-file-based data outputs.

Attributes: format (FileFormat): The format of the file. If not provided, it will be inferred from the file extension. uri (str | list[str]): The URI of the files with format: 's3://path/to/files'. It can be a single URI or a list of URIs. credentials (S3Credentials): The credentials required to access the S3 bucket.

Initializes the S3Destination with the given URI and the credentials required to access the S3 bucket, and optionally a format and date and time after which the files were modified.

Parameters

parameter
uristr | list[str]

The URI of the files with format: 's3://path/to/files'. It can be a single URI or a list of URIs.

parameter
credentialsS3Credentials

The credentials required to access the S3 bucket. Must be a S3Credentials object.

parameter
formatstr | FileFormat, optional

The format of the file. If not provided, it will be inferred from the file extension of the data. Can be either a string with the format or a FileFormat object. Currently supported formats are 'csv', 'parquet', 'ndjson' and 'jsonl'.

parameter
regionstr, optional

The region where the S3 bucket is located. If not provided, the default AWS region will be used.

Raises

OutputConfigurationError FormatConfigurationError

Properties

property
allow_fragmentsbool

Whether to allow fragments in the output.

property
catalogAWSGlue

Catalog: The catalog to store the data in.

property
credentialsS3Credentials | S3AccessKeyCredentials

S3Credentials: The credentials required to access the S3 bucket.

property
formatFileFormat

The format of the file. If not provided, it will be inferred from the file.

property
regionstr | None

str: The region where the S3 bucket is located.

property
uristr | list[str]

The URI of the files with format: 's3://path/to/files'.

SupportedFormats
class SupportedFormats(*args, **kwds)

Bases: Enum

Enum for the supported formats for the S3Destination.

attribute
avro

attribute
csv

attribute
ndjson

attribute
parquet

Methods

chunk
def chunk(working_dir: str, *results)

Trigger the exporting of the data to local parquet chunks. This method will receive the resulting data from the user function and must store it in the local system as parquet files, using the working_dir. Note: This method should not materialize the data, it should only store it in the local system.

Parameters:

parameter
working_dirstr

The folder where any files generated must be stored (this refers to temporary files that will be deleted after the execution of the plugin, not the final destination of the data)

parameter
results

The data to be exported. It is a list of polars LazyFrames or None.

Returns:

A list of the intermediate files created

stream
def stream(working_dir: str, *results)

Trigger the exporting of the data. This method will receive the resulting data from the user function and must store it in the desired location. Note: this method might materialize the data provided in a single chunk generated by the chunk function if invoked, so chunks should be of an appropriate size.

Parameters:

parameter
working_dirstr

The folder where any intermediate files generated must be stored (this refers to temporary files that will be deleted after the execution of the plugin, not the final destination of the data)

parameter
results

The data to be exported. It is a list of polars LazyFrames or None.

Returns:

None