microsoft/semantic-link-labs · Archived

direct-lake-operations

Guide for working with Direct Lake semantic models. Use this when implementing Direct Lake-related features or troubleshooting.

First seen May 5, 2026

Installation

$ npx skills add microsoft/semantic-link-labs --skill direct-lake-operations

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from microsoft/semantic-link-labs · top by installs.

npx skills add microsoft/semantic-link-labs

Browse all from microsoft/semantic-link-labs

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 573
License LICENSE
Default branch main
Open issues 45
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 8,291 B
  • docs SUMMARY.md 157 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 9 installs

SKILL.md

Direct Lake Operations

This skill covers working with Direct Lake semantic models in Semantic Link Labs.

When to Use This Skill

Use this skill when you need to:

  • Migrate models to Direct Lake
  • Check and fix Direct Lake fallback issues
  • Sync schema between lakehouse and model
  • Work with Direct Lake guardrails
  • Warm Direct Lake cache

Overview

Direct Lake is a storage mode for Power BI semantic models that reads data directly from Delta tables in OneLake, providing fast query performance without data import.

Key Files

File Purpose
src/sempy_labs/directlake/ Direct Lake submodule
dlhelper.py Core Direct Lake utilities
_guardrails.py Guardrail checking
directlakeschema_sync.py Schema synchronization
warmcache.py Cache warming utilities

Direct Lake Functions

Core Functions

Function Purpose
checkfallbackreason Check why model falls back to DirectQuery
getdirectlake_lakehouse Get lakehouse connected to model
getdirectlake_source Get SQL endpoint and lakehouse info
generatedirectlakesemanticmodel Create new Direct Lake model

Schema Management

Function Purpose
directlakeschema_compare Compare model schema with lakehouse
directlakeschema_sync Sync model schema from lakehouse

Guardrails

Function Purpose
getdirectlake_guardrails Get guardrail limits for model
getskusize Get SKU capacity info
getdirectlakeguardrailsforsku Get guardrails for specific SKU

Cache Management

Function Purpose
warmdirectlakecacheisresident Warm cache using IsResident
warmdirectlakecacheperspective Warm cache using perspective

Connection Updates

Function Purpose
updatedirectlakemodelconnection Update lakehouse connection
updatedirectlakemodellakehouse_connection Legacy connection update

Checking Fallback Reasons

Direct Lake models can fall back to DirectQuery mode. Use checkfallbackreason to diagnose:

from sempy_labs.directlake import check_fallback_reason

# Check specific model
result = check_fallback_reason(
    dataset="My Direct Lake Model",
    workspace="My Workspace"
)

# Returns DataFrame with fallback reasons per table
print(result)

Common Fallback Reasons

Reason Cause Solution
ColumnNotInPartition Column missing from Delta table Add column to lakehouse table
ParquetTypeMismatch Data type mismatch Update lakehouse table schema
UnsupportedFilter DAX filter not supported Modify DAX query
Guardrail Exceeded capacity limits Upgrade capacity or reduce data

Schema Synchronization

Compare Schemas

from sempy_labs.directlake import direct_lake_schema_compare

# Compare model schema with lakehouse tables
comparison = direct_lake_schema_compare(
    dataset="My Direct Lake Model",
    workspace="My Workspace"
)

# Shows differences between model and lakehouse
print(comparison)

Sync Schema

from sempy_labs.directlake import direct_lake_schema_sync

# Sync model schema from lakehouse
direct_lake_schema_sync(
    dataset="My Direct Lake Model",
    workspace="My Workspace",
    add_columns=True,      # Add new columns
    remove_columns=False,  # Keep columns not in lakehouse
)

Guardrails

Direct Lake has limits based on capacity SKU:

from sempy_labs.directlake import get_direct_lake_guardrails

# Get guardrails for a model
guardrails = get_direct_lake_guardrails(
    dataset="My Direct Lake Model",
    workspace="My Workspace"
)

# Shows limits vs current values
print(guardrails)

Guardrail Limits

Guardrail Description
Max Rows Per Table Maximum rows per table
Max Size Per Table Maximum table size in GB
Max Columns Per Table Maximum columns per table
Max Model Size Maximum total model size

Generating Direct Lake Models

Create a new Direct Lake model from lakehouse tables:

from sempy_labs.directlake import generate_direct_lake_semantic_model

# Generate model from lakehouse
generate_direct_lake_semantic_model(
    dataset="New Direct Lake Model",
    lakehouse="My Lakehouse",
    workspace="My Workspace",
    lakehouse_workspace="Lakehouse Workspace",  # Optional
)

Updating Connections

Change the lakehouse a Direct Lake model points to:

from sempy_labs.directlake import update_direct_lake_model_connection

# Update to different lakehouse
update_direct_lake_model_connection(
    dataset="My Direct Lake Model",
    workspace="My Workspace",
    target_lakehouse="New Lakehouse",
    target_workspace="Target Workspace",
)

Cache Warming

Warm the Direct Lake cache after model refresh:

Using IsResident

from sempy_labs.directlake import warm_direct_lake_cache_isresident

# Warm columns that were previously in memory
warm_direct_lake_cache_isresident(
    dataset="My Direct Lake Model",
    workspace="My Workspace"
)

Using Perspective

from sempy_labs.directlake import warm_direct_lake_cache_perspective

# Warm columns defined in a perspective
warm_direct_lake_cache_perspective(
    dataset="My Direct Lake Model",
    perspective="Cache Warming",
    workspace="My Workspace"
)

Migration to Direct Lake

The library provides migration tools in src/sempy_labs/migration/:

Migration Workflow

  1. Migrate calculated tables to lakehouse as Delta tables
  2. Create Direct Lake model with same structure
  3. Migrate measures and other objects
  4. Validate and test

Example Migration

from sempy_labs.migration import (
    migrate_calctables_to_lakehouse,
    migrate_model_objects_to_semantic_model,
)

# Step 1: Migrate calculated tables to lakehouse
migrate_calctables_to_lakehouse(
    dataset="Source Import Model",
    workspace="My Workspace",
    lakehouse="Target Lakehouse",
    lakehouse_workspace="Lakehouse Workspace",
)

# Step 2: Migrate other objects (measures, etc.)
migrate_model_objects_to_semantic_model(
    source_dataset="Source Import Model",
    target_dataset="Target Direct Lake Model",
    source_workspace="My Workspace",
    target_workspace="My Workspace",
)

Best Practices

Do's

  • ✅ Always check guardrails before deploying
  • ✅ Use schema sync after lakehouse changes
  • ✅ Warm cache after scheduled refreshes
  • ✅ Monitor fallback reasons regularly

Don'ts

  • ❌ Don't ignore fallback warnings
  • ❌ Don't exceed guardrail limits
  • ❌ Don't modify lakehouse schema without syncing model
  • ❌ Don't use unsupported DAX patterns

Troubleshooting

Model Falls Back to DirectQuery

  1. Run checkfallbackreason() to identify cause
  2. Check column mappings with directlakeschema_compare()
  3. Verify data types match between model and lakehouse
  4. Check guardrails with getdirectlake_guardrails()

Schema Mismatch

  1. Run directlakeschema_compare() to see differences
  2. Run directlakeschema_sync() to fix mismatches
  3. Verify partition entity mappings

Performance Issues

  1. Check cache state with warmdirectlakecacheisresident()
  2. Verify partitions are properly configured
  3. Review query patterns for unsupported filters

Related Resources

Resource URL
Direct Lake Overview Microsoft Docs
Guardrails Microsoft Docs
Migration Notebook Notebook
API Docs ReadTheDocs