dbt (data build tool) interview questions

31. Do I need to add a yaml entry for column for it to appear in the docs site?
no.dbt will introspect your warehouse to generate a list of columns in each relation, and match it with the list of columns in your .yml files.

32. Can I document things other than models, like sources, seeds, and snapshots?
Yes! You can document almost everything in your project using the description.

33. How to debug if any of the tests failed?
To debug a failing test, find the SQL that dbt ran by:
dbt Cloud:
Within the test output, click on the failed test, and then select “Details”
dbt CLI:
Open the file path returned as part of the error message.
Navigate to the target/compiled/schema_tests directory for all compiled test queries
Copy the SQL into a query editor (in dbt Cloud, you can paste it into a new Statement), and run the query to find the records that failed.

34. If the compiled SQL has a lot of spaces and new lines, how can I get rid of it?
This is known as “whitespace control”.
Use a minus sign (-, e.g. {{- … -}}, {%- … %}, {#- … -#}) at the start or end of a block to strip whitespace before or after the block

35. How do I preserve leading zeros in a seed?
If you need to preserve leading zeros (for example in a zipcode or mobile number):
v0.16.0 onwards: Include leading zeros in your seed file, and use the column_types configuration with a varchar datatype of the correct length.
Prior to v0.16.0: Use a downstream model to pad the leading zeros using SQL, for example: lpad(zipcode, 5, ‘0’)

Author: user

Leave a Reply

Your email address will not be published. Required fields are marked *