March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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
Running DESCRIBE DETAIL delta.`Tables/rdm/bank_holidays_eng` returns NULL for name
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.
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
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.
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
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
13 | |
4 | |
3 | |
3 | |
2 |