Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dagster-dbt] add with_snowflake/bigquery_insights chainable method #23183

Merged
merged 10 commits into from
Jul 24, 2024

Conversation

benpankow
Copy link
Member

@benpankow benpankow commented Jul 23, 2024

Summary

Adds a with_snowflake_insights and with_bigquery_insights methods that can be chained to a .stream() call, simplifying using insights alongside other deferred fetches:

Before:

@dbt_assets(manifest=snowflake_manifest_path)
def jaffle_shop_dbt_assets(
    context: AssetExecutionContext,
    dbt: DbtCliResource,
):
    dbt_cli_invocation = dbt.cli(["build", "--profile", "unittest"], context=context)
    yield from dbt_with_snowflake_insights(context, dbt_cli_invocation)

Now:

@dbt_assets(manifest=snowflake_manifest_path)
def jaffle_shop_dbt_assets(
    context: AssetExecutionContext,
    dbt: DbtCliResource,
):
    yield from dbt.cli(
        ["build", "--profile", "unittest"], context=context
    ).stream().with_snowflake_insights()

Test Plan

https://github.com/dagster-io/internal/pull/10731

@benpankow
Copy link
Member Author

benpankow commented Jul 23, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @benpankow and the rest of your teammates on Graphite Graphite

@benpankow benpankow changed the title [dagster-dbt] add with_snowflake_insights chainable method [dagster-dbt] add with_snowflake/bigquery_insights chainable method Jul 23, 2024
Copy link
Contributor

@rexledesma rexledesma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just have one function, with_insights? We can determine whether the target is snowflake or bigquery from the execution manifest

Also, instead of an import time error, maybe we could raise a warning instead, so core execution doesn't fail? We should also add a test in the OSS context (the warning is thrown since dagster-cloud isn't installed)

@benpankow
Copy link
Member Author

benpankow commented Jul 23, 2024

Can we just have one function, with_insights? We can determine whether the target is snowflake or bigquery from the execution manifest

Good call; updated.

Also, instead of an import time error, maybe we could raise a warning instead, so core execution doesn't fail? We should also add a test in the OSS context (the warning is thrown since dagster-cloud isn't installed)

My bias is for the code to explicitly error here just so there's no silent failure or other unexpected behavior - in the case that a user is conditionally using different warehouses, I think they can just conditionally call this method. They'd have to do a fair amount of conditional logic (manifest, target) elsewhere anyway.

Copy link
Contributor

@rexledesma rexledesma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we should just universally have the config check enabled? That way, we can remove it as an argument. But we should probably ensure that check is done at the start of the dbt cli invocation so that things fail fast.

Not a blocker to get this initial scaffold in though

@benpankow benpankow force-pushed the benpankow/add-with-snowflake-insights branch from 20c7e81 to a561f57 Compare July 24, 2024 15:59
@benpankow benpankow merged commit 9fbdd2f into master Jul 24, 2024
1 check was pending
@benpankow benpankow deleted the benpankow/add-with-snowflake-insights branch July 24, 2024 16:13
sryza pushed a commit that referenced this pull request Jul 24, 2024
…#23183)

## Summary

Adds a `with_snowflake_insights` and `with_bigquery_insights` methods
that can be chained to a `.stream()` call, simplifying using insights
alongside other deferred fetches:

Before:

```python
@dbt_assets(manifest=snowflake_manifest_path)
def jaffle_shop_dbt_assets(
    context: AssetExecutionContext,
    dbt: DbtCliResource,
):
    dbt_cli_invocation = dbt.cli(["build", "--profile", "unittest"], context=context)
    yield from dbt_with_snowflake_insights(context, dbt_cli_invocation)

```


Now:

```python
@dbt_assets(manifest=snowflake_manifest_path)
def jaffle_shop_dbt_assets(
    context: AssetExecutionContext,
    dbt: DbtCliResource,
):
    yield from dbt.cli(
        ["build", "--profile", "unittest"], context=context
    ).stream().with_snowflake_insights()
```

## Test Plan

dagster-io/internal#10731
benpankow added a commit that referenced this pull request Aug 6, 2024
## Summary

Adds docs for the new insights API introduced in #23183
benpankow added a commit that referenced this pull request Aug 7, 2024
Adds docs for the new insights API introduced in #23183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants