dbt_utils 1.0 fails to handle empty strings in slugify
Describe the bug
In the 1.0 release, dbt_utils.slugify was changed to prepend an underscore if the string has a leading digit, but fails to handle empty strings.
Steps to reproduce
Call dbt_utils.slugify('').
Expected results
I think an empty string should be returned, rather than the user having to check if the string is empty first.
Actual results
A compilation error is raised with str object has no element 0.
Screenshots and log output
When compiling a model that calls slugify.
15:39:45 Encountered an error:
Compilation Error in model fct_payments_rides_v2 (models/mart/payments/fct_payments_rides_v2.sql)
str object has no element 0
> in macro create_row_access_policy (macros/create_row_access_policy.sql)
> called by macro slugify (macros/jinja_helpers/slugify.sql)
> called by model fct_payments_rides_v2 (models/mart/payments/fct_payments_rides_v2.sql)
System information
The contents of your packages.yml file:
packages:
- package: dbt-labs/dbt_utils
version: 1.0.0
- package: calogica/dbt_expectations
version: [">=0.8.0", "<0.9.0"]
Which database are you using dbt with?
- [ ] postgres
- [ ] redshift
- [x] bigquery
- [ ] snowflake
- [ ] other (specify: ____________)
The output of dbt --version:
dbt --version actually hangs for me right now 🤔
Additional context
see link above
Are you interested in contributing the fix?
Sure I think it's a 1-line change.
Hey @atvaccaro, good catch! I'd welcome a fix for this - agreed that if it's an empty string, we can just return the empty string.
Please also add a test for this in the slugify tests model
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.
Hi all, did we find a fix for this. I am encountering this issue and would appreciate any help to fix it. Thanks.
Hi all, did we find a fix for this. I am encountering this issue and would appreciate any help to fix it. Thanks.
+1
@dkeyer-twilio this has been fixed in main, but it has not been released yet. It will be included in our next release (which hasn't been scheduled yet).