Skip to main content
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
pmscorca
Post Prodigy
Post Prodigy

Creating a table template for a lakehouse

Hi,

I'm trying to create a reusable table template to create an empty table on a lakehouse using a Spark notebook.

I'm trying this pyspark code:

from pyspark.sql.types import StructType, StructField, StringType, IntegerType, DateType, TimestampType
#from pyspark.sql.types import VarcharType, CharType
from datetime import datetime

#table template
schema = StructType([
    StructField("code", StringType(), True),  # string field
    StructField("description", StringType(), True),  # string field
    StructField("revenue", IntegerType(), True),  # integer field
    StructField("insert_date", DateType(), True),  # date field
    StructField("insert_datetime", TimestampType(), True)  # datetime field
])


If possible, I'd like to use also the VarcharType() and the CharType, specifying a dimension. It should be useful specifying a dimension also for the IntegerType(). I've accomplish some proofs and it seems that the VarcharType() and the CharType() with a specified dimensione aren't supported.

Any suggests to me to complete this template? Thanks

1 ACCEPTED SOLUTION
frithjof_v
Super User
Super User
2 REPLIES 2
frithjof_v
Super User
Super User

Hi, thanks your suggest is good and interesting.

I'd like to use pyspark to solve this issue.

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Weeks

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (25)