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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pmscorca
Post Patron
Post Patron

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
Community Champion
Community Champion
2 REPLIES 2
frithjof_v
Community Champion
Community Champion

Hi, thanks your suggest is good and interesting.

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.