Skip to content
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

[Bug] dbt_utils.get_url_parameter does not work for databricks #55

Closed
2 of 4 tasks
fivetran-joemarkiewicz opened this issue Nov 10, 2023 · 1 comment
Closed
2 of 4 tasks
Assignees
Labels
error:forced priority:p3 Affects many users; can wait status:in_progress Currently being worked on type:bug Something is broken or incorrect update_type:feature Primary focus is to add new functionality

Comments

@fivetran-joemarkiewicz
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

When using Databricks the get_url_parameter macro does not work and results in the below error. This is the result of the get_url_parameter macro (and subsequently the split macro) attempting to pull the index 1. However, if the index 1 does not exist in the data then it will result in the below error. Other warehouses are able to circumvent this due to a safe offset. However, databricks does not have this function.

Relevant error log or model output

19:50:59  Runtime Error in model linkedin_ads__url_report (models/linkedin_ads__url_report.sql)
19:50:59    [INVALID_ARRAY_INDEX] The index 1 is out of bounds. The array has 1 elements. Use the SQL function `get()` to tolerate accessing element at invalid index and return NULL instead. If necessary set "ansi_mode" to "false" to bypass this error.
19:50:59    == SQL of VIEW stg_linkedin_ads__creative_history(line 289, position 5) ==
19:50:59        split(
19:50:59        ^^^^^^
19:50:59            click_uri,
19:50:59    ^^^^^^^^^^^^^^^^^^
19:50:59            
19:50:59    ^^^^^^^^
19:50:59    
19:50:59    
19:50:59            -- escape if starts with a special character
19:50:59    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19:50:59            case when regexp_extract('utm_source=', '([^A-Za-z0-9])(.*)', 1) != '_'
19:50:59    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19:50:59                then concat('\\', 'utm_source=')
19:50:59    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19:50:59                else 'utm_source=' end
19:50:59    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19:50:59    
19:50:59    
19:50:59        
19:50:59    ^^^^
19:50:59            )[(1)]
19:50:59    ^^^^^^^^^^^^^^

Expected behavior

The get_url_parameter works without failure

dbt Project configurations

Latestt

Package versions

Latest

What database are you using dbt with?

databricks

dbt Version

1.7.0

Additional Context

No response

Are you willing to open a PR to help address this issue?

  • Yes.
  • Yes, but I will need assistance and will schedule time during our office hours for guidance
  • No.
@fivetran-catfritz fivetran-catfritz self-assigned this Nov 16, 2023
@fivetran-catfritz fivetran-catfritz added priority:p3 Affects many users; can wait type:bug Something is broken or incorrect status:in_progress Currently being worked on update_type:feature Primary focus is to add new functionality labels Nov 20, 2023
@fivetran-catfritz fivetran-catfritz linked a pull request Nov 20, 2023 that will close this issue
7 tasks
@fivetran-joemarkiewicz
Copy link
Contributor Author

The latest release of this package has been updated to use the custom linkedin_source.extract_url_parameter() macro. This addresses the immediate issue raised in this feature request. However, in the next breaking change of this package we will want to remove the custom macro and swap the package to leverage the fivetran_utils.extract_url_parameter() macro.

This was not implemented originally as it could possibly have caused breaking changes, we wanted to address the issue in a timely manner while ensuring we did not break any transformation pipelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error:forced priority:p3 Affects many users; can wait status:in_progress Currently being worked on type:bug Something is broken or incorrect update_type:feature Primary focus is to add new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants