-
Notifications
You must be signed in to change notification settings - Fork 227
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 failing to execute CREATE TABLE command because it assigned a column DEFAULT value #1085
Comments
Hello @dbeatty10 , |
@shloktech curious if you would be willing to share with me why you're using the dbt-spark adapter for Databricks rather than the dbt-databricks adapter? |
Hello @amychen1776 , I am using dbt-databricks 1.8.4 at my end. Below is a sample of my profiles.yml:
cc: @dbeatty10 |
Oh thank you - @dpguthrie this issue needs to be tracked with dbt-databricks then. |
Hello @amychen1776 , @dpguthrie can you please transfer the issue to dbt-databricks repo as I don't have the subsequent write access in either of the repo: cc: @dbeatty10 |
@shloktech since |
Thank you @dbeatty10 created a issue in dbt-databricks: databricks/dbt-databricks#758 |
Is this a new bug in dbt-core?
Current Behavior
I am using DBT for Data Testing. Over here I have a few not_null checks on delta tables which are in databricks and I am running them by using the below command:
dbt build --profile {our_data_testing_profile} -t {our_env} --select "models/models_to_test+" --store-failures| tee dbt_issues.log || true
Here I am storing the output of data testing into delta tables in databricks which are under dbt_test__audit schema. While doing it we are getting the below error stating:
On debugging I found that it dbt is using the below query to create table in dbt_test__audit schema from dbt.log file:
This is occurring because databricks does not let us create a table which is based on an empty dataframe.
Output of the select query:
To resolve in query we need to add the below property in the above query which is suggested by databricks as well in the error message. After this the query works as per expectations:
Even after creating the above table when I rerun the dbt test then it fails because it uses the query in first screenshot above which does not have the TBLPROPERTIES command in it. I searched in dbt documentations but did not find any option that let's me add table properties. I I run only the dbt build query then the data testing works without any error but when I run it with commands to store the results then it fails due to above TBLPROPERTIES not present in the create table query generated by dbt-core.
Expected Behavior
The expected behavior can be divided in two parts:
Steps To Reproduce
Configure a not null check on a delta table in databricks which will pass.
Run the below command:
dbt build --profile {your_data_testing_profile} -t {your_environment} --select "models/models_to_test+" --store-failures| tee dbt_issues.log || true
Make sure that the target for storing the results is databricks. Secondly the source table which is undergoing data test has a column which has default value assigned to it like below:
You will get the below error for your test case:
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
other (mention it in "Additional Context")
Additional Context
The adapter used is Databricks
The text was updated successfully, but these errors were encountered: