def generate_external_dataset(output_url='file:///tmp/external_dataset'):
    """Creates an example dataset at output_url in Parquet format"""
    spark = SparkSession.builder \
        .master('local[2]') \
        .getOrCreate()
    sc = spark.sparkContext

    rows_count = 10
    rows_rdd = sc.parallelize(range(rows_count)) \
        .map(row_generator)

    spark.createDataFrame(rows_rdd). \
        write. \
        mode('overwrite'). \
        parquet(output_url)
Creates an example dataset at output_url in Parquet format
examples/hello_world/external_dataset/generate_external_dataset.py