Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .opencode/skills/dbt-analyze/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ If no manifest is available:
1. Run `lineage_check` on the changed SQL
2. Show column-level data flow
3. Note: downstream impact requires a manifest
4. Suggest: `altimate-dbt build-project` to generate one
4. Suggest: `altimate-dbt build` to generate one

## Common Mistakes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ altimate-dbt info # Project name, adapter, root
## Build & Run

```bash
altimate-dbt build --model <name> [--downstream] # compile + run + test
altimate-dbt build # full project build (compile + run + test)
altimate-dbt build --model <name> [--downstream] # build a single model
altimate-dbt run --model <name> [--downstream] # materialize only
altimate-dbt test --model <name> # run tests only
altimate-dbt build-project # full project build
```

## Compile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ altimate-dbt info # Project name, adapter, root
## Build & Run

```bash
altimate-dbt build --model <name> [--downstream] # compile + run + test
altimate-dbt build # full project build (compile + run + test)
altimate-dbt build --model <name> [--downstream] # build a single model
altimate-dbt run --model <name> [--downstream] # materialize only
altimate-dbt test --model <name> # run tests only
altimate-dbt build-project # full project build
```

## Compile
Expand Down
4 changes: 2 additions & 2 deletions .opencode/skills/dbt-docs/references/altimate-dbt-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ altimate-dbt info # Project name, adapter, root
## Build & Run

```bash
altimate-dbt build --model <name> [--downstream] # compile + run + test
altimate-dbt build # full project build (compile + run + test)
altimate-dbt build --model <name> [--downstream] # build a single model
altimate-dbt run --model <name> [--downstream] # materialize only
altimate-dbt test --model <name> # run tests only
altimate-dbt build-project # full project build
```

## Compile
Expand Down
4 changes: 2 additions & 2 deletions .opencode/skills/dbt-test/references/altimate-dbt-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ altimate-dbt info # Project name, adapter, root
## Build & Run

```bash
altimate-dbt build --model <name> [--downstream] # compile + run + test
altimate-dbt build # full project build (compile + run + test)
altimate-dbt build --model <name> [--downstream] # build a single model
altimate-dbt run --model <name> [--downstream] # materialize only
altimate-dbt test --model <name> # run tests only
altimate-dbt build-project # full project build
```

## Compile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ altimate-dbt info # Project name, adapter, root
## Build & Run

```bash
altimate-dbt build --model <name> [--downstream] # compile + run + test
altimate-dbt build # full project build (compile + run + test)
altimate-dbt build --model <name> [--downstream] # build a single model
altimate-dbt run --model <name> [--downstream] # materialize only
altimate-dbt test --model <name> # run tests only
altimate-dbt build-project # full project build
```

## Compile
Expand Down
2 changes: 1 addition & 1 deletion packages/dbt-tools/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { DBTProjectIntegrationAdapter, CommandProcessResult } from "@altima

export async function build(adapter: DBTProjectIntegrationAdapter, args: string[]) {
const model = flag(args, "model")
if (!model) return { error: "Missing --model" }
if (!model) return project(adapter)
const downstream = args.includes("--downstream")
const result = await adapter.unsafeBuildModelImmediately({
plusOperatorLeft: "",
Expand Down
6 changes: 1 addition & 5 deletions packages/dbt-tools/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ const USAGE = {
info: "Get project info (paths, targets, version)",
compile: "Compile a model (Jinja to SQL) --model <name>",
"compile-query": "Compile a raw query --query <sql> [--model <name>]",
build: "Build a model --model <name> [--downstream]",
build: "Build project, or a single model with --model <name> [--downstream]",
run: "Run a model --model <name> [--downstream]",
test: "Test a model --model <name>",
"build-project": "Build entire project",
execute: "Execute SQL --query <sql> [--model <name>] [--limit <n>]",
columns: "Get columns of model --model <name>",
"columns-source": "Get columns of source --source <name> --table <name>",
Expand Down Expand Up @@ -171,9 +170,6 @@ async function main() {
case "test":
result = await (await import("./commands/build")).test(adapter, rest)
break
case "build-project":
result = await (await import("./commands/build")).project(adapter)
break
case "execute":
result = await (await import("./commands/execute")).execute(adapter, rest)
break
Expand Down
57 changes: 57 additions & 0 deletions packages/dbt-tools/test/build.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { describe, test, expect, mock } from "bun:test"
import { build } from "../src/commands/build"
import type { DBTProjectIntegrationAdapter } from "@altimateai/dbt-integration"

function makeAdapter(overrides: Partial<DBTProjectIntegrationAdapter> = {}): DBTProjectIntegrationAdapter {
return {
unsafeBuildModelImmediately: mock(() => Promise.resolve({ stdout: "model built", stderr: "" })),
unsafeBuildProjectImmediately: mock(() => Promise.resolve({ stdout: "project built", stderr: "" })),
unsafeRunModelImmediately: mock(() => Promise.resolve({ stdout: "", stderr: "" })),
unsafeRunModelTestImmediately: mock(() => Promise.resolve({ stdout: "", stderr: "" })),
dispose: mock(() => Promise.resolve()),
...overrides,
} as unknown as DBTProjectIntegrationAdapter
}

describe("build command", () => {
test("build without --model builds entire project", async () => {
const adapter = makeAdapter()
const result = await build(adapter, [])
expect(adapter.unsafeBuildProjectImmediately).toHaveBeenCalledTimes(1)
expect(adapter.unsafeBuildModelImmediately).not.toHaveBeenCalled()
expect(result).toEqual({ stdout: "project built" })
})

test("build --model <name> builds single model", async () => {
const adapter = makeAdapter()
const result = await build(adapter, ["--model", "orders"])
expect(adapter.unsafeBuildModelImmediately).toHaveBeenCalledTimes(1)
expect(adapter.unsafeBuildModelImmediately).toHaveBeenCalledWith({
plusOperatorLeft: "",
modelName: "orders",
plusOperatorRight: "",
})
expect(adapter.unsafeBuildProjectImmediately).not.toHaveBeenCalled()
expect(result).toEqual({ stdout: "model built" })
})

test("build --model <name> --downstream sets plusOperatorRight", async () => {
const adapter = makeAdapter()
await build(adapter, ["--model", "orders", "--downstream"])
expect(adapter.unsafeBuildModelImmediately).toHaveBeenCalledWith({
plusOperatorLeft: "",
modelName: "orders",
plusOperatorRight: "+",
})
})

test("build surfaces stderr as error", async () => {
const adapter = makeAdapter({
unsafeBuildProjectImmediately: mock(() =>
Promise.resolve({ stdout: "partial output", stderr: "compilation error", fullOutput: "" }),
),
})
const result = await build(adapter, [])
expect(result).toEqual({ error: "compilation error", stdout: "partial output" })
})
})
Loading