Pyspark StructType is not defined December 8, 2023 by Tarik Did you import StructType? If not from pyspark.sql.types import StructType should solve the problem.