-
Notifications
You must be signed in to change notification settings - Fork 504
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
Update generate_surrogate_key(...)
to return NULL
when some columns are NULL
#935
Comments
This seems like one of the best things about If there is a column generated via
Why wouldn't adding a |
Depending on the use case, not returning
This is one example with 2 columns, and yes, in that case, it is "easy" to add a test on The slight difference as well is that, in the example before Another slight annoyance is that in |
I'm going to close this feature request as "not planned". It's a strength that the In terms of the other considerations you raised:
|
Describe the feature
Today,
generate_surrogate_key()
will never return aNULL
value. Ifmy_col
contains someNULL
, evengenerate_surrogate_key(["my_col")]
will never beNULL
Describe alternatives you've considered
Add a second argument to
generate_surrogate_key
to list what columns, ifNULL
should generate aNULL
surrogate key.dbt_utils.generate_surrogate_key(field_list = ['field_a', 'field_b'], nullable_list = ['field_b'] )
would returnNULL
for the rows wherefield_b
is NULL.Additional context
People generally put a
unique
andnot_null
tests on their keys. If their key is a surrogate key, testing fornot_null
ongenerate_surrogate_key
will actually use some compute for nothing, and will not check what pepople might be expecting.Who will this benefit?
All people using
generate_surrogate_key
and wanting more control on what columns are allowed to beNULL
or not.Are you interested in contributing this feature?
Sure.
The text was updated successfully, but these errors were encountered: