04 / 06Intermediate
Run the project
Run PySpark
Navigate to the PySpark directory
cd pysparkGenerate dummy data
The script writes the dummy data to the database of whichever node is currently active.
python seed_products.pyExecute PySpark functionality
The next step pulls every record from the node, loads the records into a PySpark DataFrame, and runs a set of analyses on it.
Note: Large datasets can trigger a Java OutOfMemoryError, which happens when PySpark exhausts its heap memory. You can avoid this by adding the environment variables below to your
.envfile before you start the script:
On Linux, macOS, or WSL:
# Set these environment variables before running your scriptexport SPARK_DRIVER_MEMORY=2gexport SPARK_EXECUTOR_MEMORY=2gexport SPARK_DRIVER_MAXRESULTSIZE=1gOn Windows:
# Set these environment variables before running your scriptset SPARK_DRIVER_MEMORY=2gset SPARK_EXECUTOR_MEMORY=2gset SPARK_DRIVER_MAXRESULTSIZE=1gThen start the script:
python get_products_paginated.pyWritten for this site from Chromia’s public course. Code samples are the course’s own.