dbt-labs / dbt-labs/dbt

[BUG][Databricks] AI_QUERY optional named arguments fail static analysis

Open
#15,656 0 comments 0 reactions 0 assignees View on GitHub
adapter:databricks area:static-analysis type:bug
Dominant language
Rust
Stars
13.8k
Forks
2.6k
Avg merge
21h 31m
Merged PRs (30d)
56

Description

### Describe the bug

Fusion only recognizes the two-argument Databricks `AI_QUERY` signature during static analysis. A valid Databricks call using `responseFormat` and `failOnError` fails to compile in strict mode.

This is related to the Databricks AI/LLM function work tracked in #15087, but I could not find an issue covering `AI_QUERY` itself.

### Reproduction

Use a Databricks model containing:

```sql
select ai_query(
endpoint => 'my-serving-endpoint',
request => 'Return a JSON response',
responseFormat => '{"type":"json_schema","json_schema":{"name":"response","schema":{"type":"object","properties":{"result":{"type":"string"}},"required":["result"],"additionalProperties":false},"strict":true}}',
failOnError => false
) as response
```

Then run:

```shell
dbt compile --static-analysis strict
```

Fusion reports:

```text
dbt0209: Failed to resolve function AI_QUERY: Argument type mismatch:
actual: (endpoint => string, request => string, responseFormat => string, failOnError => boolean)
candidates: (endpoint => string, request => string)
```

The same SQL is valid in Databricks. Removing `responseFormat` and `failOnError` makes Fusion compile it, but changes the behavior: `responseFormat` is needed for schema-constrained output, and `failOnError` controls how inference failures are handled.

### Expected behavior

Fusion static analysis should recognize the documented optional named arguments for the Databricks `AI_QUERY` function, including `responseFormat` and `failOnError`.

### Environment

- dbt Fusion: `2.0.0-preview.202`
- Adapter/platform: Databricks
- OS: Linux x86-64

### Workaround

Set `static_analysis='baseline'` on the affected model.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.