Skip to content

Instantly share code, notes, and snippets.

@gsunita
gsunita / export-pyspark-schema-to-json.py
Created July 9, 2021 19:15 — forked from stefanthoss/export-pyspark-schema-to-json.py
Export/import a PySpark schema to/from a JSON file
import json
from pyspark.sql.types import *
# Define the schema
schema = StructType(
[StructField("name", StringType(), True), StructField("age", IntegerType(), True)]
)
# Write the schema
with open("schema.json", "w") as f: