An exporter is a custom python function in a file located in the folder exports in the root of the repository.
from typing import Dict
from pyspark.sql import SparkSession, DataFrame, functions as f
def export(
segment: str,
segment_df: DataFrame,
segment_config: Dict,
export_config: Dict,
):
spark = SparkSession.getActiveSession()
output_path = export_config["path"]
output_blob_path = f"/dbfs/fake_azure_blob{output_path}/{segment}.csv"
(
segment_df.withColumn("segment", f.lit(segment_config["name"]))
.toPandas()
.to_csv(output_blob_path, index=False)
)
Config for this export
segmentfactory:
segments:
customers_who_might_be_interested_in_investments:
name: "Zájemci o investice"
exports:
- "main_azure_blob_export"
exports:
main_azure_blob_export:
type: "azure_blob"
path: "/exports/segments"
attributes:
- "customer_email"