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
MattSB
Frequent Visitor

Lakehouse with Schema Bug - Not generating proper metadata

HI ive ran into a problem while testing the Lakehouse with schema. The issue appears that the creation of the deltatable is not populating the standard meta data correctly 

 

Issue

- lakehouse called 'bronze' with a schema called `rdm`.

- Notebook requesting data from gov.uk API adding to a datframe and loading to a delta table.

- Issues identified

  1. In the properties pane Format is not  populated.
    MattSB_1-1735635570616.png

     

  2.  Running `spark.catalog.listTables()` returns an empty list
  3.  Running `spark.sql("show tables")` returns an empty data frame
  4. Running `DESCRIBE DETAIL rdm.bank_holidays_eng` returns an odd name but is returning the format of delta
    MattSB_2-1735635853087.png
  5. Running DESCRIBE DETAIL delta.`Tables/rdm/bank_holidays_eng` returns NULL for name 

    MattSB_4-1735636050165.png

     

Test Scenario

- Notebook loading 

# load the requests library
import requests

# define the url
url = "https://www.gov.uk/bank-holidays/england-and-wales.json"

# make a GET request 
response = requests.get(url)

# Process the response json 
response_data = response.json()

## Create the data frame ##

# Load modules
from pyspark.sql.types import StructType, StructField, StringType, DateType
from datetime import datetime

# Convert date strings to date objects, handling blank strings
def convert_date(date_str):
    return datetime.strptime(date_str, '%Y-%m-%d').date() if date_str else None

# Extract the list of results
parsed_data = [(item['title'], convert_date(item['date'])) for item in response_data['events']]

# Define the schema
schema = StructType([
    StructField("holiday", StringType(), True, {"comment": "Name of holiday"}),
    StructField("date", DateType(), True, {"comment": "Date of holiday"})
])

# Create DataFrame 
df = spark.createDataFrame(parsed_data , schema )

# Order the results
df = df.orderBy(df["date"].asc())

# Show the dataframe
df.show()

## Store data in delta table ##

delta_table_path = "bronze.rdm.bank_holidays_eng" 
#also tried using the table path and same behaviour "Tables/rdm/bank_holidays_eng"

# Write the DataFrame to a Delta table
df.write.format("delta").mode("overwrite").saveAsTable(delta_table_path)

Any advice would be appreciated.

 

 

 

3 REPLIES 3
MattSB
Frequent Visitor

HI nithin,

Thanks for confirming, i was sort of hoping after 4 months in preview the schema functionality would be closer to production by now. 

 

Can you confirm if I use your suggested process will appends and overwrites work still? 

 

Hi @MattSB ,
you can still append or overwrite to the table in your default schema and then drag and drop the table to a different schema.

But if you  are trying to append or overwrite to a table in different schema using SQL endpoint( or Spark SQL) would be the better option.
Thanks and regards

v-nmadadi-msft
Community Support
Community Support

Hi @MattSB  ,
Thanks for reaching out to the Microsoft fabric community forum.

Currently as the lakehouse schemas is still in public preview some of the features are not yet supported. One of them is adding a delta table in our desired schema. Currently we can load df into the default schema.

vnmadadimsft_0-1735655662710.png

 

 But we can then move the delta table to the schema we want.

Once the delta table is created in default schema we can just drag and drop it from default schema to the one we want

vnmadadimsft_1-1735655677643.png

 

vnmadadimsft_2-1735655677644.png

 

 

 

 

Alterantively you can also use DDL commands (Alter tables) in SQL endpoint to move the delta table

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to give "Kudos"

Thanks and Regards

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!

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.