Skip to content

Max Recursion config property #613

@cody-scott

Description

@cody-scott

We have come across some tables that require a recursion limit of greater then 100, the SQL Server default. Proposing to add a config property to insert a variable max recursion amount.

The current adapter implements the options here
https://github.com/dbt-msft/dbt-sqlserver/blob/master/dbt/include/sqlserver/macros/adapter/metadata.sql

Since the option maxrecursion cannot be apart of the create view statement, this should only apply to the create table statements. Based on how this is set now it would either need to be changed for all calls to check if its a table materialization or we have an alternative table version that adds maxrecursion.

My suggestion would be to have it always include the maxrecursion in the option, but have the default be 100 to mimic the sql server default.

apply_label appears in a few spots, so perhaps the simpler option is have apply_label_for_table as a starting point. We wouldn't have to change the apply_label signature to require a materialization type argument in that case.

https://github.com/search?q=repo%3Adbt-msft%2Fdbt-sqlserver%20apply_label&type=code

Option

{% macro apply_label() %}
    {{ log (config.get('query_tag','dbt-sqlserver'))}}
    {%- set query_label = config.get('query_tag','dbt-sqlserver') -%}
    OPTION (LABEL = '{{query_label}}');
{% endmacro %}

{% macro apply_label_for_table() %}
    {{ log (config.get('query_tag','dbt-sqlserver'))}}
    {%- set query_label = config.get('query_tag','dbt-sqlserver') -%}
    {%- set max_recursion = config.get('max_recursion',100) -%}
    OPTION (
        LABEL = '{{query_label}}', 
        MAXRECURSION = {{ max_recursion }}
    );
{% endmacro %}

then change the call here:

{%- set query_label = apply_label() -%}

{% macro sqlserver__create_table_as(temporary, relation, sql) -%}
    {%- set query_label = apply_label_for_table() -%}
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions