dbt-labs / dbt-labs/dbt

[Bug] UDFs (User Defined Function) end up in wrong schema due to ignoring generate_schema_name macro

Open
#12,849 1 comment 3 reactions 0 assignees View on GitHub
engine:v1 status:triage type:bug
Dominant language
Rust
Stars
13.8k
Forks
2.6k
Avg merge
21h 31m
Merged PRs (30d)
56

Description

### Is this a new bug in dbt-core?

- [x] I believe this is a new bug in dbt-core
- [x] I have searched the existing issues, and I could not find an existing issue for this bug

### Current Behavior

When defining a UDF the schema name is compiled literally as configured.

When there are 2 developers working on the same repo they might interfere with each other or worse with code already merged. If I define the schema to be `udf_schema` it ends up in `udf_schema`

### Expected Behavior

When defining a UDF I would expect the configured schema name to be based to the generate_schema_name macro.

We use the generate_schema_name macro to separate the workspaces while developing. In my case everything I do ends up in a schema called `dbt_dikootje`. So When I define the schema to be `udf_schema` I'd expect it to end up in `dbt_dikootje` and not overwrite whatever might already be touched by peers.

### Steps To Reproduce

1. Create a UDF `test_udf` in functions
2. Create a yml file with the UDF specs and configure the schema as `int`
3. Create a sql model using the UDF
4. Hit compile
5. Verify the compiled sql.

This will now refer to `database`.`int`.`test_udf` and not the expected `database`.`dbt_dikootje`.`test_udf`.

This causes problems with coworkers running the same project as well as during CI builds

### Relevant log output

```shell

```

### Environment

```markdown
- OS: Windows 11
- Python: 3.13.5
- dbt: 1.11.8
```

### Which database adapter are you using with dbt?

snowflake

### Additional Context

_No response_

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.