agentleFS
MicrosoftKnown publishermicrosoft/dbt-fabricspark/.github/copilot-instructions.md

dbt-fabricspark

Copilot instructions70 starsChanged 7 months agoMITView on GitHub

πŸ›‘ DO NOT ADD UNNECESSARY COMMENTS IN THE CODE πŸ›‘ A dbt adapter that lets dbt-core build SQL models against Apache Spark in Microsoft Fabric. It connects to Fabric Lakehouses via the Livy API (or a local Livy in the devcontainer for offline work) and ships materializations for table, view, incremental, seed, snapshot, and materialized_lake_view. Auto-detects schema-enabled vs non-schema lakehouses (four-part/three-part vs two-part naming) and supports cross-lakehouse writes via database overrides on a single profile. CI (.github/workflows/ci.yml) runs

  • Reads credentials

The file

We split this copilot-instructions.md into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • β‰ˆ0

    Common Β· estimate

    Many files like this have a rule of this kind.

  • β‰ˆ3

    Distinctive Β· estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do NOT add flowery comments in the code all over the place.

    line 5
  2. Distinctive:

    Do NOT indirectly refer to Github issues in the actual code.

    line 6
  3. Distinctive:

    When in doubt, ask rather than guess.

    line 89

β‰ˆ β€œCommon” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. β€œVery specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

Copilot Instructions β€” dbt-fabricspark

Comments in code

  • Do NOT add flowery comments in the code all over the place. The code is self-descriptive, ONLY add comments when the code is doing something non-orthodox
  • Do NOT indirectly refer to Github issues in the actual code. The codebase has nothing to do with Github, it's self-contained.

πŸ›‘ DO NOT ADD UNNECESSARY COMMENTS IN THE CODE πŸ›‘

What this repo is

A dbt adapter that lets dbt-core build SQL models against Apache Spark in Microsoft Fabric.

It connects to Fabric Lakehouses via the Livy API (or a local Livy in the devcontainer for offline work) and ships materializations for table, view, incremental, seed, snapshot, and materialized_lake_view.

Auto-detects schema-enabled vs non-schema lakehouses (four-part/three-part vs two-part naming) and supports cross-lakehouse writes via database overrides on a single profile.

Key paths

PathWhat lives there
src/dbt/adapters/fabricspark/Python adapter β€” impl.py, connections.py, livysession.py, credentials.py, mlv_api.py, shortcuts.py
src/dbt/include/fabricspark/macros/Jinja SQL macros (adapters/, materializations/{models,seeds,snapshots}, utils/)
src/dbt/include/fabricspark/{dbt_project.yml,profile_template.yml}Adapter package + profile prompts
tests/unit/Pure pytest unit tests β€” no Fabric needed
tests/functional/Live-Fabric functional tests, orchestrator.py, YAML scheduler, test_config.yaml
tests/fixtures/dbt-jaffle-shop/Project used by the local end-to-end test
tools/scripts/run.shSingle entry point that every Nx target shells out to
tools/gh-automation/TypeScript helpers for managing Copilot-driven PRs
docker/Compose.sqlserver.metastore.yamlSQL Server Hive metastore for the local-e2e flow
.devcontainer/Prebuilt devcontainer image (pinned by digest) used locally and in CI
.github/workflows/ci.ymlThe CI pipeline
project.json / nx.jsonNx target definitions β€” the source of truth for build/lint/test
pyproject.tomlPython deps (uv-managed), ruff config, pytest config
CHANGELOG.md / docs/RELEASE_CHECKLIST.mdManual changelog + release flow

CI is the contract β€” run it locally with npx nx

CI (.github/workflows/ci.yml) runs inside the prebuilt devcontainer image and invokes npx nx affected ... -t {build|lint|test} --configuration=ci, followed by npm run fail-on-untracked-files. Everything Nx runs delegates to tools/scripts/run.sh <target>, which auto-creates a .venv via uv β€” never call pip directly.

The Nx targets defined in project.json (run them with npx nx run dbt-fabricspark:<target>):

Nx targetCommandWhat it does
lintnpx nx run dbt-fabricspark:lintruff check --fix + ruff format + verify clean
buildnpx nx run dbt-fabricspark:builduv build wheel + twine check
testnpx nx run dbt-fabricspark:testAggregate: test:unit β†’ test:functional β†’ test:local-e2e
test:unitnpx nx run dbt-fabricspark:test:unituv run pytest tests/unit -vv
test:functionalnpx nx run dbt-fabricspark:test:functionalYAML-scheduled live-Fabric run (provision β†’ warm sessions β†’ pytest xdist β†’ nuke); needs test.env
test:local-e2enpx nx run dbt-fabricspark:test:local-e2eFull dbt lifecycle on local Livy + jaffle-shop; depends on build and init
initnpx nx run dbt-fabricspark:initBrings up local Livy (depends on metastore-up)
metastore-up/downnpx nx run dbt-fabricspark:metastore-upSQL Server Hive metastore via Docker Compose
cleannpx nx run dbt-fabricspark:cleanTears down Livy/metastore, removes dist/, caches, __pycache__
publishnpx nx run dbt-fabricspark:publishtwine check + uv publish (no-op without UV_PUBLISH_TOKEN)

To match CI's affected-only mode locally, prefix with the same flags:

npx nx affected --base=origin/main -t lint --configuration=ci --output-style=stream
npx nx affected --base=origin/main -t build --configuration=ci --output-style=stream
npx nx affected --base=origin/main -t test --configuration=ci --output-style=stream

For one-off pytest runs while iterating:

uv run pytest tests/unit/test_adapter.py::TestSparkAdapter::test_profile_with_database -vv

Robust CI tests are non-negotiable

  • Full Fabric CI suite must run locally For validation, you must run npx nx run test. The secrets should already be hydrated locally in the git repo under test.env by the human user during repo setup.
  • Every change must keep lint, build, test (all targets) green. Do not gate features on flaky assumptions about Fabric availability β€” wrap external calls with the retry/backoff and timeout knobs already on FabricSparkCredentials (http_timeout, session_start_timeout, statement_timeout, poll_wait, poll_statement_wait, connect_retries, retry_all).
  • Functional tests run in parallel across two lakehouses (no_schema and with_schema) and across multiple Livy sessions via xdist β€” see tests/functional/test_config.yaml and tests/functional/conftest.py. New tests must be xdist-safe and must not assume which session they land on. Use the existing fail-fast sentinel (--fail-fast-sentinel) instead of inventing new abort mechanisms.
  • Unit tests should cover any branch in impl.py/connections.py/livysession.py/mlv_api.py you touch, including the schema-detection heuristic (parse-time schema != lakehouse) and credential masking.
  • fail-on-untracked-files will fail CI if you leave a regenerated file uncommitted β€” this catches stale uv.lock after a dep change. Always commit lockfile updates that result from your edits.
  • Devcontainer image is pinned by digest in .devcontainer/devcontainer.json and .github/workflows/ci.yml. Don't hand-edit these; rebuild via the flow in .devcontainer/README.md.

Do not assume β€” ask first

Adapter behavior is subtle (schema-enabled detection, cross-lakehouse routing, session reuse, MLV semantics, Livy retry policy). Before making non-trivial changes:

  • Confirm scope with the user. Is this a bug fix, a new materialization option, or a behavior change to an existing one? Should it apply to schema-enabled mode, non-schema mode, or both?
  • Confirm test strategy. Unit-only, or does it need a functional test against real Fabric? Which Fabric runtime/lakehouse type is in scope?
  • Confirm public-API impact. Does this change FabricSparkCredentials fields, profile YAML keys, or model config() keys? If so, the README config tables and profile_template.yml need updates too.
  • Confirm changelog placement. New version section in CHANGELOG.md, or append to the unreleased section?

When in doubt, ask rather than guess. The maintainers prefer a question to a wrong assumption that ships.

Do not commit without review

The repo owner reviews all changes before merge β€” open a PR and wait for review. Don't run git commit autonomously on main, and follow Conventional Commits for PR titles (the PR template will remind you).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.