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

Add null equality condition to equals macro #744

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

VersusFacit
Copy link
Contributor

@VersusFacit VersusFacit commented Jan 27, 2025

resolves #110
followup to #383 #394

Note: still needs the athena test skip fix to be merged into main

Problem

We need to add the capability for the equals macro to way the presence of no values. However, this is a huge blast radius and doesn't suit all use cases. So we'd like to add it behind a behavior flag and through customer use of this different behavior determine in the future what would be a better long-term solution while also delivering the customer value we need now. A complete solution will require far more investigation outside of this effort.

Solution

The equals macro can be configured at the dbt_project.yml level. Special attention is given to bigquery tests in this poor request because turning this flag on or off results in many errors across our current tests. This macro does not play well with sophisticated partitioning. A follow on snowflake PR is coming that will make use of this behavior and test it even more thoroughly.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX


{% macro default__equals(expr1, expr2) -%}
{%- if adapter.behavior.enable_truthy_nulls_equals_macro.no_warn %}
case when (({{ expr1 }} = {{ expr2 }}) or ({{ expr1 }} is null and {{ expr2 }} is null))
Copy link
Contributor

@colin-rogers-dbt colin-rogers-dbt Jan 28, 2025

Choose a reason for hiding this comment

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

next year we'll enable "extra truthy" nulls and support or ({{ expr1 }}= '' and {{ expr2 }} is null)

body: Added new equals macro that handles null value checks in sql
time: 2024-12-17T11:05:36.363421+02:00
custom:
Author: adrianburusdbt
Copy link
Contributor

Choose a reason for hiding this comment

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

@VersusFacit don't forget to add yourself as an author as well

Also not sure this is "under the hood" as we're making a meaningful improvement to how snapshots/tests work

Copy link
Contributor

@colin-rogers-dbt colin-rogers-dbt left a comment

Choose a reason for hiding this comment

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

minor nit on changelog but otherwise LGTM

mikealfare pushed a commit that referenced this pull request Jan 29, 2025
* TableLastModifiedMetadataBatch capability

* pin ddtrace

* open connection before calculate_freshness_from_metadata_batch

* remove calculate_freshness_from_metadata_batch override

* changelog entry

* TestGetLastRelationModifiedBatch

* restore dev-requirements.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes The PR author has signed the CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants