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

[CT-2634] [Bug] not {{ equals(actual, expected) }} isn't working properly #7778

Closed
2 tasks done
dbeatty10 opened this issue Jun 4, 2023 · 0 comments · Fixed by #7776
Closed
2 tasks done

[CT-2634] [Bug] not {{ equals(actual, expected) }} isn't working properly #7778

dbeatty10 opened this issue Jun 4, 2023 · 0 comments · Fixed by #7776
Labels
bug Something isn't working

Comments

@dbeatty10
Copy link
Contributor

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Surfaced by @lllong33 in #7670 (comment):

@sdebruyn @dbeatty10 It looks like not null is not true, can't write it like that. FYI

select version();  -- PostgreSQL 12.3 on x86_64-pc-linux-gnu

with t1 as (
	select 1 as actual, 2 as expected
	union all 
	select 1 as actual, 1 as expected
	union all 
	select 1 as actual, cast(null as int) as expected
	union all 
	select cast(null as int) as actual, cast(null as int) as expected 
)

select * from t1 
--where actual = expected or (actual is null and expected is null) -- normal: 1,1; null,null
--where actual != expected 
--	or (actual is null and expected is not null )
--	or (actual is not null and expected is null ) -- normal: 1,2; 1,null
where not (actual = expected or (actual is null and expected is null)) -- issue: actual=1, expected=null is not work 

image

Expected Behavior

Negation of equals should work.

Steps To Reproduce

See #7670 (comment) for a reproduction case.

Relevant log output

No response

Environment

- OS:
- Python:
- dbt:

Which database adapter are you using with dbt?

No response

Additional Context

The three-valued logic of SQL is tricky, and we should use a "fully equivalent substitute for A is not distinct from B that works in all SQL databases."

And then we should make the sure the "adapters zone" includes relevant tests.

@dbeatty10 dbeatty10 added bug Something isn't working triage and removed triage labels Jun 4, 2023
@github-actions github-actions bot changed the title [Bug] not {{ equals(actual, expected) }} isn't working properly [CT-2634] [Bug] not {{ equals(actual, expected) }} isn't working properly Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant