Skip to content

Refactor not_empty_string macro to fix alias bugs and catch invisible…#1082

Open
shivasingh4945-tech wants to merge 1 commit into
dbt-labs:mainfrom
shivasingh4945-tech:main
Open

Refactor not_empty_string macro to fix alias bugs and catch invisible…#1082
shivasingh4945-tech wants to merge 1 commit into
dbt-labs:mainfrom
shivasingh4945-tech:main

Conversation

@shivasingh4945-tech
Copy link
Copy Markdown

What changed & why:

  • No more syntax crashes: The old code tried to alias the column (as {{ column_name }}), which broke dbt if we tested a nested column (like user.email) or a SQL function. I moved the logic straight into the WHERE clause so it works on everything.
  • Catches sneaky characters: Standard trim() was missing invisible characters like tabs and newlines. This now catches those so completely blank strings actually fail the test like they are supposed to.
  • Faster queries: Instead of doing 4 separate string scans with nested replace() functions, it now uses translate() to swap out all hidden characters in one fast pass.

Tested and verified on normal text, empty strings, spaces, tabs, and NULLs!

@shivasingh4945-tech shivasingh4945-tech requested a review from a team as a code owner April 24, 2026 21:51
@shivasingh4945-tech
Copy link
Copy Markdown
Author

Hi @remigabillet @mjumbewu @haf @zqureshi
I have tested this fix on PostgreSQL and it works correctly.

Would love your feedback on this approach.
Happy to make any changes needed!

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.

1 participant