Skip to content

[Bug] Snowfalke py_write_table ignores copy_grants setting #1249

@psolomin

Description

@psolomin

Is this a new bug?

  • I believe this is a new bug
  • I have searched the existing issues, and I could not find an existing issue for this bug

Which packages are affected?

  • dbt-adapters
  • dbt-tests-adapter
  • dbt-athena
  • dbt-athena-community
  • dbt-bigquery
  • dbt-postgres
  • dbt-redshift
  • dbt-snowflake
  • dbt-spark

Current Behavior

When a python model is used in Snowflake for "table" materializaion, new table has all grants of previous table lost.

Expected Behavior

py_write_table macro should set copy_grants config.

Steps To Reproduce

  1. Create a basic dbt project with setting
models:
  +copy_grants: true
  1. Create a model
from snowflake.snowpark import Session, DataFrame
from snowflake.snowpark import functions as F

def model(dbt, session: Session) -> DataFrame:
    dbt.config(materialized="table")
    df = session.range(1).select(F.lit(1).alias("col"))
    return df
  1. dbt run

In Snowflake query history you will see a stored procedure with python code, but copy_grants won't be in the df.write... call.

Relevant log output

Environment

- OS: mac
- Python: 3.10.9
- dbt-adapters: 1.9.2
- snowflake: 1.9.2

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage:productIn Product's queuetype:bugSomething isn't working as documented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions