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

DBT-774: Modify the macro for TestRight to return empty string('') instead of NULL #143

Closed
wants to merge 3 commits into from

Conversation

nsharma-25
Copy link
Collaborator

@nsharma-25 nsharma-25 commented Apr 10, 2024

Describe your changes

For TestRight, the current sql is mentioned below, however with this sql, in the case when length_epression = 0, we are getting NULL in actual column whereas in expected column of test_right we are getting an empty string, which is causing a mismatch between the expected and actual values.

create or replace view test_right
  
  as
    with util_data as (
    select * from data_right
)
select
    

    case when length_expression = 0
        then NULL
    else
        substr(
        string_text,
        (length(string_text)-cast(length_expression as int)+1),
        length(string_text)-1
    )
    end as actual,
    coalesce(output, '') as expected
from util_data

This PR suggests to update the macro so that instead of NULL we get an empty string in the actual column.

Internal Jira ticket number or external issue link

https://jira.cloudera.com/browse/DBT-774

Testing procedure/screenshots(if appropriate):

TestRight in v1.5 - https://gist.github.com/nsharma-25/00c62edbf737b25dae0dffca6ad9dbd5
TestRight in v1.6 - https://gist.github.com/nsharma-25/1e2b07fdf55c49bb69f82a8dcae7a3d9
All Tests in v1.5- https://gist.github.com/nsharma-25/a7368721576fb58593d4163218c5ae4e
All Tests in v1.6 - https://gist.github.com/nsharma-25/7846b543427a12517e6b2674f12feadc

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have formatted my added/modified code to follow pep-8 standards
  • I have checked suggestions from python linter to make sure code is of good quality.

Base automatically changed from changes to main April 10, 2024 19:29
@vamshikolanu
Copy link
Collaborator

@nsharma-25 This is not the right fix. Let's not change the test and do pass here.
The right fix is to return an empty string instead of NULL in the macro: https://github.com/cloudera/dbt-hive/blob/main/dbt/include/hive/macros/utils/right.sql#L19

@nsharma-25 nsharma-25 changed the title DBT-774: Changes in TestRight DBT-774: Modify the macro for TestRight to return empty string('') instead of NULL Apr 11, 2024
@nsharma-25 nsharma-25 closed this Apr 11, 2024
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.

2 participants