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

Instrument run_hooks #824

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro run_hooks(hooks, inside_transaction=True) %}
{% macro run_hooks(hooks, inside_transaction=True, span_name='run_hooks') %}
{% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}
{% if not inside_transaction and loop.first %}
{% call statement(auto_begin=inside_transaction) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% set existing_relation = load_cached_relation(this) %}
{% set target_relation = this.incorporate(type=this.DynamicTable) %}

{{ run_hooks(pre_hooks) }}
{{ run_hooks(pre_hooks, span_name='pre-hook') }}

{% set build_sql = dynamic_table_get_build_sql(existing_relation, target_relation) %}

Expand All @@ -15,7 +15,7 @@
{{ dynamic_table_execute_build_sql(build_sql, existing_relation, target_relation) }}
{% endif %}

{{ run_hooks(post_hooks) }}
{{ run_hooks(post_hooks, span_name='post-hook') }}

{% do unset_query_tag(query_tag) %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

{% set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') %}

{{ run_hooks(pre_hooks) }}
{{ run_hooks(pre_hooks, span_name='pre-hook') }}

{% if existing_relation is none %}
{%- call statement('main', language=language) -%}
Expand Down Expand Up @@ -148,7 +148,7 @@

{% do drop_relation_if_exists(tmp_relation) %}

{{ run_hooks(post_hooks) }}
{{ run_hooks(post_hooks, span_name='post-hook') }}

{% set target_relation = target_relation.incorporate(type='table') %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
table_format=config.get('table_format', 'default')
) -%}

{{ run_hooks(pre_hooks) }}
{{ run_hooks(pre_hooks, span_name='pre-hook') }}

{% if target_relation.needs_to_drop(existing_relation) %}
{{ drop_relation_if_exists(existing_relation) }}
Expand All @@ -26,7 +26,7 @@
{{ create_table_as(False, target_relation, compiled_code, language) }}
{%- endcall %}

{{ run_hooks(post_hooks) }}
{{ run_hooks(post_hooks, span_name='post-hook') }}

{% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}
{% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ eventually be retired in favor of a standardized approach. Changed line:
type='view') -%}
{% set grant_config = config.get('grants') %}

{{ run_hooks(pre_hooks) }}
{{ run_hooks(pre_hooks, span_name='pre-hook') }}

-- If there's a table with the same name and we weren't told to full refresh,
-- that's an error. If we were told to full refresh, drop it. This behavior differs
Expand All @@ -66,7 +66,7 @@ eventually be retired in favor of a standardized approach. Changed line:
{% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}
{% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}

{{ run_hooks(post_hooks) }}
{{ run_hooks(post_hooks, span_name='post-hook') }}

{{ return({'relations': [target_relation]}) }}

Expand Down
Loading