split_part
doesn't work when using a negative index on BigQuery
#557
Labels
bug
Something isn't working
split_part
doesn't work when using a negative index on BigQuery
#557
Describe the bug
In BigQuery, the macro split_part does not return results when the part_number is negative (e.g. when we want to get items from the end of the string and not the beginning)
Steps to reproduce
select {{ dbt_utils.split_part("'1/2/3/4.sql'", "'/'", -1) }}
which translates to
select split('1/2/3/4.sql','/')[safe_offset(-1 -1)]
Expected results
4.sql
Actual results
Null
Which database are you using dbt with?
Are you interested in contributing the fix?
Happy to contribute or let another person do it.
The macro needs to be changed so we can add a check on whether
part_number
is negative, and if it is, the macro needs to returnThe text was updated successfully, but these errors were encountered: