Forum Discussion
Refresh SQL Endpoint using semantic link labs: Intermittent failures
- 1 year ago
Final Solution was to get rid of semantic labs approach and use directl ythe api as shown here
Example code using the new fabric rest api · GitHub
Thx
Hi,
Add the time delay did not make any difference. It's quite clear that for some reasons call to API that manage trhe refresh of the SQL Endpoint fails but no idea why.
I have tested that scheduling the notebook to run at different times, sometimes works fine others not
Success execution\\
Failed execution
but I am not able to undertand what make the difference to make it fail. Same lakehouse, same tables,....
Alfons
- v-dineshya1 year agoCommunity Support
Hi alfBI ,
Thank you for reaching out to the Microsoft Community Forum.
The intermittent failures when using the refresh_sql_endpoint_metadata function from the semantic-link-labs library in Microsoft Fabric, particularly encountering a KeyError related to missing DataFrame columns.
Please refer below workarounds.
1. Validate DataFrame Columns Before Access. Add a check before accessing the columns
expected_cols = ['Table Name', 'Status', 'Start Time', 'End Time', 'Last Successful Time']
if all(col in x.columns for col in expected_cols):
display(x[expected_cols])
else:
print("Expected columns not found. DataFrame is likely empty.")
expected_cols = ['Table Name', 'Status', 'Start Time', 'End Time', 'Last Successful SyncNote: This prevents the notebook from failing when the DataFrame is empty.
2. Make sure at least one table exists in the Lakehouse before triggering the refresh. You can add a pre-check using the semantic-link-labs API to list tables and confirm presence.
3. Wrap the refresh logic in a try-except block
try:
x = labs.refresh_sql_endpoint_metadata(item=item, type=type, workspace=workspace, tables=tables)
display(x)
except KeyError as e:
print(f"KeyError encountered: {e}")Note: This helps log errors and optionally retry or skip execution
4. If you are using a multi-step ETL/ELT pipeline, consider forcing a sync of the T-SQL endpoint using Semantic link.
I hope this information helps. Please do let us know if you have any further queries.
Regards,
Dinesh