# pyspark code to create a hive parititon table
# importing modules
from pyspark.sql import SparkSession
# Create a SparkSession with Hive support enabled
spark = SparkSession.builder.enableHiveSupport().getOrCreate()
# Create a DataFrame with sample data
data = [
("John", 25, "Male"),
("Alice", 30, "Female"),
("Bob", 27, "Male"),
("Emma", 28, "Female"),
("David", 32, "Male"),
("Sophia", 29, "Female"),
("James", 31, "Male"),
("Olivia", 26, "Female"),
("Ethan", 33, "Male"),
("Isabella", 27, "Female")
]
df = spark.createDataFrame(data, ["Name", "Age", "Gender"])
table_name = "my_partitioned"
# Create a partitioned Hive table
df.write.partitionBy("Gender").saveAsTable(table_name)
# display the table
df.show()