Skip to main content

Add credentials

  1. Create a new pipeline or open an existing pipeline.
  2. Expand the left side of your screen to view the file browser.
  3. Scroll down and click on a file named io_config.yaml.
  4. Enter the following keys and values under the key named default (you can have multiple profiles, add it under whichever is relevant to you)
For a local Spark session:
For a remote Spark cluster, set SPARK_HOST to the Spark master URL (for example, spark://host:7077, local[*], or another valid SparkSession.builder.master(...) value). You can also set SPARK_METHOD (e.g. session) and SPARK_SCHEMA to control how the session is created and which default database/schema is used.

Using Python block

  1. Create a new pipeline or open an existing pipeline.
  2. Add a data loader, transformer, or data exporter block (the code snippet below is for a data loader).
  3. Select Generic (no template).
  4. Enter this code snippet (note: change the config_profile from default if you have a different profile):
  1. Run the block.

Data Preview for Spark paths

In Mage Pro, Data Preview can read file-backed Spark datasets without requiring a persistent Hive metastore table. Use a configured Spark profile and select a project-relative path with one of the supported Spark file formats: parquet, csv, json, or orc. For example, a Spark Data Preview source can target a Parquet dataset stored under the Mage project:
The path must resolve inside the Mage project directory. If you need catalog table discovery across separate Spark sessions or worker processes, configure a durable Spark catalog or metastore and use the table name instead.

Export a dataframe to Spark

Notes

  • Spark runs in-process; ensure PySpark and any required cluster dependencies are installed in your Mage environment.
  • For local development, SPARK_HOST: local typically creates a session with SparkSession.builder.master('local').getOrCreate().
  • Use SPARK_SCHEMA to set the default database/schema for queries and exports.