2.10.7

SparkToParquetEncoder

Package: flyteplugins.spark

Parameters

def SparkToParquetEncoder()

Extend this abstract class, implement the encode function, and register your concrete class with DataFrameTransformerEngine so that the Flyte type engine can handle dataframe libraries. This is the encoding interface: it is used when the Flyte type engine converts a Python value into a Flyte Literal. For the other direction, see DataFrameDecoder.

Properties

Property Type Description
protocol Optional[str]
python_type Type[T]
supported_format str

Methods

Method Description
encode() Even if the user code returns a plain dataframe instance, the dataset transformer engine will wrap the incoming dataframe with defaults set for that dataframe type.

encode()

def encode(
    dataframe: flyte.io._dataframe.dataframe.DataFrame,
    structured_dataset_type: flyteidl2.core.types_pb2.StructuredDatasetType,
) -> flyteidl2.core.literals_pb2.StructuredDataset

Even if the user code returns a plain dataframe instance, the dataset transformer engine will wrap the incoming dataframe with defaults set for that dataframe type. This simplifies this function’s interface as a lot of data that could be specified by the user using the

TODO: Do we need to add a flag to indicate if it was wrapped by the transformer or by the user?

Parameter Type Description
dataframe flyte.io._dataframe.dataframe.DataFrame This is a DataFrame wrapper object. See more info above.
structured_dataset_type flyteidl2.core.types_pb2.StructuredDatasetType This the DataFrameType, as found in the LiteralType of the interface of the task that invoked this encoding call. It is passed along to encoders so that authors of encoders can include it in the returned literals.DataFrame. See the IDL for more information on why this literal in particular carries the type information along with it. If the encoder doesn’t supply it, it will also be filled in after the encoder runs by the transformer engine.

Returns

This function should return a DataFrame literal object. Do not confuse this with the DataFrame wrapper class used as input to this function - that is the user facing Python class. This function needs to return the IDL DataFrame.