dbt-labs/dbt-core · error
get_temp_relation_path: relation.database is required
Error message
get_temp_relation_path: relation.database is required
What it means
An InvalidOperation minijinja error from get_temp_relation_path stating that `relation.database` is required. The callable extracts database and identifier attributes from a relation Value; if database is missing, not a string, or an empty string, no valid temp path can be built and the error is thrown.
Source
Thrown at crates/dbt-adapter/src/adapter/mod.rs:4161
"get_temp_relation_path" => {
// model: Any, batch_id: str = ""
let iter = ArgsIter::new(name, &["relation"], args);
let relation_val = iter.next_arg::<&Value>()?;
let batch_id = iter.next_kwarg::<Option<&str>>("batch_id")?.unwrap_or("");
iter.finish()?;
let database = relation_val
.get_attr("database")
.ok()
.and_then(|v| {
if v.is_undefined() || v.is_none() {
None
} else {
v.as_str().map(|s| s.to_owned())
}
})
.filter(|s| !s.is_empty())
.ok_or_else(|| {
minijinja::Error::new(
minijinja::ErrorKind::InvalidOperation,
"get_temp_relation_path: relation.database is required",
)
})?;
let identifier = relation_val
.get_attr("identifier")
.ok()
.and_then(|v| {
if v.is_undefined() || v.is_none() {
None
} else {
v.as_str().map(|s| s.to_owned())
}
})
.filter(|s| !s.is_empty())
.ok_or_else(|| {
minijinja::Error::new(
minijinja::ErrorKind::InvalidOperation,View on GitHub (pinned to 0267ce9170)
Solutions
- Ensure the relation has a non-empty string `database` before calling, e.g. `this.database` from a fully qualified relation.
- If your adapter legitimately has no database, provide a default database name in profiles/relations instead of leaving it empty.
- Fix the relation construction so database is set (check quoting/`render` of the relation object).
- Guard the call: only invoke get_temp_relation_path when `relation.database` is truthy.
Example fix
// before
{% set path = get_temp_relation_path(relation, batch_id) %} // relation.database == ''
// after
{% if relation.database %}{% set path = get_temp_relation_path(relation, batch_id) %}{% endif %} Defensive patterns
Strategy: validation
Validate before calling
{% if relation.database is not defined or not relation.database %}
{% do exceptions.raise_compiler_error('relation.database required for temp relation path') %}
{% endif %} Type guard
fn has_database(v: &Value) -> bool {
v.get_attr("database").ok().and_then(|d| d.as_str().map(|s| !s.is_empty())).unwrap_or(false)
} Try / catch
match database { Some(db) if !db.is_empty() => ..., _ => Err(invalid_operation("relation.database is required")) } Prevention
- Use fully qualified relations (`this.database`) in temp-relation flows
- Configure a default database for adapters without a database concept
- Validate relation attributes at construction time
When it happens
Trigger: Calling get_temp_relation_path with a relation whose `database` attribute is absent, null, an empty string, or a non-string Value (e.g. an object from a custom relation class that overrides database).
Common situations: Databases that intentionally have no database concept (e.g. SQLite/DuckDB-style) combined with temp-relation features; relations built by hand without database; cross-project relations where quoting dropped the field.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- get_temp_relation_path: relation.identifier is required
- {} relation creation from Jinja values
- Unknown method on BaseRelationObject: '{name}'
- Unknown method on StaticBaseRelationObject: '{name}'
- Failed to convert quoting to resolved quoting
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/ec10fb1e41467eed.
Report an issue: GitHub.