Forum Discussion
roalexan
Microsoft Employee
2 years agocreate Lakehouse table using pyspark
Hello all. At a high level, I'm trying to create an EventStream that reads from an EventHub as a streaming source, and writes to a Fabric Lakehouse as a destination (using this blog sample, BTW). Foc...
- Anonymous2 years ago
Hi roalexan
Thanks for using Fabric Community.
1) Please attach the lakehouse to the notebook.
2) Then try running this code:from pyspark.sql.types import StructType, StructField, IntegerType, StringType schema = StructType([ StructField("Id", IntegerType(), False), StructField("Name", StringType(), True) ]) df = spark.createDataFrame([], schema) df.write.format("delta").saveAsTable("table2")
This will create a new table named "table2" in your lakehouse.Hope this helps. Please let me know if you have any further questions. Glad to help.