Apply expectations only if column exists
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2024 05:46 AM
Hi, is there any way to apply a expectations only if that column exists? I am creating multiple dlt tables with the same python function so i would like to create diferent expectations based in the table name, currently i only can create expectations for those column that exists in all the tables created for the python function
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2024 06:02 AM
To apply expectations only if a column exists in Delta Live Tables (DLT), you can use the @Dlt.expect
decorator conditionally within your Python function. Here is a step-by-step approach to achieve this:
- Check if the Column Exists: Before applying the expectation, check if the column exists in the DataFrame.
- Apply Expectations Conditionally: Use the
@Dlt.expect
decorator only if the column is present.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2024 06:32 AM
Hi Walter, sorry what would it look like in the code?
i can do this in the python function (it does nothing)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2024 06:50 AM

