-
Notifications
You must be signed in to change notification settings - Fork 607
Open
Labels
Description
Describe the feature
Send Query ... returned no rows message from get_single_value macro to the debug log, consistent with similar logging output for get_column_values - see:
Would entail changing print to log in the get_single_value macro. If required, the macro could be updated with a 'quiet' parameter instead to simply not return any output if no value found.
Describe alternatives you've considered
To get around this we have coded manually using run_query(), replacing the print() statement with a log() statement:
{% if execute %}
{% set query_result = run_query(warehouse_query).columns[0].values() %}
{% set result_count = (query_result | length) %}
{% if result_count != 0 %}
{% set warehouse_name = query_result[0] %}
{% else %}
{{ log("Query: " ~ warehouse_query ~ " returned zero rows") }}
{% set warehouse_name = none %}
{% endif %}
{% endif %}Additional context
Database-agnostic
Who will this benefit?
Reduces log noise. We use a 'warehouse recommender' script in Snowflake - when it doesn't return records we get messages in the main dbt log:
03:15:05 Query `select lower('db_'||replace(recommended_warehouse,'[ENV]','prd')) from db_prd_stage.audit.warehouse_recommender where lower(dbt_object_name) = 'bring'` returned no rows. Using the default value: None
03:15:05 Query `select lower('db_'||replace(recommended_warehouse,'[ENV]','prd')) from db_prd_stage.audit.warehouse_recommender where lower(dbt_object_name) = 'production'` returned no rows. Using the default value: None
03:15:05 Query `select lower('db_'||replace(recommended_warehouse,'[ENV]','prd')) from db_prd_stage.audit.warehouse_recommender where lower(dbt_object_name) = 'likely'` returned no rows. Using the default value: None
03:15:05 Query `select lower('db_'||replace(recommended_warehouse,'[ENV]','prd')) from db_prd_stage.audit.warehouse_recommender where lower(dbt_object_name) = 'those'` returned no rows. Using the default value: None
Are you interested in contributing this feature?
I can contribute to the feature.
Reactions are currently unavailable