[BUG] [DuckDB] grants error w/ "Fusion has no method: `warn_once`" instead of warning
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
## Summary
DuckDB doesn't support grants, the dbt Core v1 DuckDB adapter addressed this shortcoming by warning the user once then doing a no-op.
More info:
- https://github.com/duckdb/dbt-duckdb/issues/458
- https://github.com/duckdb/dbt-duckdb/pull/459 that adds a new Python Adapter method, `.warn_once()`, that is invoked inside of the `duckdb__apply_grants` macro by @jwills
- internal automated reproduction of the issue: https://github.com/dbt-labs/scratch/pull/135
- similar precedent but for an adjacent feature: https://github.com/dbt-labs/fs/pull/10127
In Fusion, DuckDB models that configure `grants` fail with the following error because it does not have this `adapter.warn_once()` method, so in the scenario of grants being configured in a duckdb project, the user gets a panic via the adapter's `UnknownMethod` arm.
```
[JinjaError (dbt1501)]: Error executing materialization macro
'dbt_duckdb.materialization_table_duckdb' for model ...:
Failed to eval the compiled Jinja expression unknown method:
map has no method named warn_once
(in dbt_internal_packages/dbt-duckdb/macros/adapters.sql:259:7)
(in dbt_internal_packages/dbt-adapters/macros/adapters/apply_grants.sql:152:31)
```
FWIW the `duckdb__apply_grants` is the only place that `adapter.warn_once()` is used.
## Rationale for warning and not erroring
Reading https://github.com/duckdb/dbt-duckdb/issues/458, the rationale to warn instead of error at parse time was
> to facilitate smoother migration from other query engines to duckdb
## Solutions
I see these as the options:
1. in the `duckdb__apply_grants() macro replace `adapter.warn_once()` with `exceptions.warn()` proposed by @pgoslatara in https://github.com/duckdb/dbt-duckdb/pull/758
2. add support to Core v2 for `adapter.warn_once()` but more canonically for Core v2
3. improve dbt Core v2 so that:
1. it intentionally errors at parse time
2. but with a friendlier a similar message to what dbt Core v1 warns about
3. allows users to opt-out of the error
I'm open to any of the options and defer to @dbt-labs/fusion-adapters
I had Claude take a stab at option 2 in https://github.com/dbt-labs/fs/pull/10873. However, I'm not convinced that it's a canonical implementation bc I believe we have better ways to detect and warn.
Contributor guide
Assessment
This issue has not been assessed yet.