Hello, <#C02CTC89LAX|> <@U02BVBCC0CC> . Is it po...
# community-support
m
Hello, #C02CTC89LAX @Maayan Salom . Is it possible in the elementary that whenever any test case will fail we can get exact rows of that table? For example, in the below example a test case failed. But, I cannot see which exact rows got affected by this falling condition.
w
Hi, oh yes, this function has been working great ever since for me. Also, in the public demo this functionality is present. See here: https://storage.googleapis.com/elementary_static/elementary_demo.html#/report/test-results Maybe your test case has not failed yet or you executed elementary on prod but looking at dev results or something like that?
m
Hey, thanks much for the answer. I attached an example below. For the email column, not_null test cases fail. So, now it's only showing null values of email. But, if I want to see entire table columns which can actually help me to understand which are the rows failing? For example, payment table has 4 columns including email. So, now email column has some null values. Now, I want to check which rows are affected including other columns too. If you need any further information feel free to ask me.
w
I see. You don't want to see the values of the field which break the test but the entire row where this non-compliant value belongs to. That functionality I haven't seen. What I do is that I copy the generated SQL code (given under "result Query") and execute it. Often, you just need to change the select.
👍 1
m
Thanks for the quick response. Looking forward to this feature in elementary. It would be super helpful 🤩
j
Can you share the compiled code for your
not_null
test on this field? I’m guessing it looks something like
Copy code
SELECT email
FROM {{ table }}
WHERE email IS NULL
I think if the test were written like this
Copy code
SELECT *
FROM {{ table }}
WHERE email IS NULL
Then in elementary you would see all the columns for the failing rows. I’m not an elementary dev, but based on my experience the test previews in the elementary report show the same columns as the stored test failures table in my data warehouse. So you may need to modify the test definition to alter what is seen in the report. Good luck!
m
Hey, can you tell me if it is possible to modify the test as you wrote then I can see all the records?
j
I think this documentation should have everything you need to customize a built in test: https://docs.getdbt.com/best-practices/writing-custom-generic-tests#customizing-dbts-built-in-tests
m
Hey @joshuah.kapilivsky, I tried your way and it is working well. Big thanks to you 🙌. I am getting this thing, add a description but I tried to add this code snippet still not able to get the description. Could you please tell me if you know?
j
Glad it worked for you! Sorry but I haven’t experimented much with the test description section. Not sure how to help there
o
Hi @Manav Paneliya, glad to see you got the test results sample working drop stoked as for the description, can you share your
yml
file, i would like to see how you set it up 😄
m
Hey, here is .yml file - name: stg_inventory columns: - name: inventory_id # Unique Tests tests: - unique: alias: dim_order_item_unique_id - not_null - name: stock_quantity tests: - warn_if_unique - warn_if_not_unique - name: last_updated tests: - warn_if_null
o
i cant find where you have set the
meta.description
property in those tests. if, for example, you want to add it to the test
dim_order_item_unique_id
, then it should look like so:
Copy code
- name: stg_inventory
    columns:
      - name: inventory_id
        # Unique Tests
        tests:
          - unique:
              alias: dim_order_item_unique_id
              meta:
                description: "This is a very cool test:)"
m
Hey @Ofek Weiss, i have added it this way and it is working. - name: stock_quantity tests: - warn_if_unique: meta: description: ' It is checking for unique values' Can you please guide me on this? I have 6 failed test cases and why is it showing only 5?
o
Amazing 🤩 As for the cases you see in the report, it shows just a sample of the failing rows (the default is 5) You can change it using the test_sample_row_count var to your dbt project
m
Fabulous. It is working well. Thanks much ! Can you tell me where I can find this doc on the web because I didn’t find this thing in elementary docs?
o
Currently it is not documented very well sadly, only appearing in this page of our docs, ill make sure it is documented better 🙂
😍 1
m
Thanks much for the quick response . I really appreciate it 😎