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

enable web/ macros (e.g. dbt_utils.get_url_parameter()) #66

Open
dataders opened this issue Nov 9, 2021 · 0 comments
Open

enable web/ macros (e.g. dbt_utils.get_url_parameter()) #66

dataders opened this issue Nov 9, 2021 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@dataders
Copy link
Contributor

dataders commented Nov 9, 2021

dbt_utils.get_url_parameter() doesn't work currently (neither does get_url_host or get_url_path).

I think it has to do with dbt_utils.split_part:

{% macro sqlserver__split_part(string_text, delimiter_text, part_number) %}
LTRIM(CAST(('<X>'+REPLACE({{ string_text }},{{ delimiter_text }} ,'</X><X>')+'</X>') AS XML).value('(/X)[{{ part_number }}]', 'VARCHAR(128)'))
{% endmacro %}

dbt-utils's integration test message is:

('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]XML parsing: line 1, character 56, semicolon expected (9411) (SQLMoreResults)')

this was the generated SQL by the integration tests...

with data as (
    select * from "dbt-msft-serverless-db"."test"."data_urls"
)

select
    nullif(

    LTRIM(CAST(('<X>'+REPLACE(

    LTRIM(CAST(('<X>'+REPLACE(url,'utm_medium=' ,'</X><X>')+'</X>') AS XML).value('(/X)[2]', 'VARCHAR(128)'))

,'&' ,'</X><X>')+'</X>') AS XML).value('(/X)[1]', 'VARCHAR(128)'))

    ,'') as actual,
    medium as expected

from data

union all

select
    nullif(

    LTRIM(CAST(('<X>'+REPLACE(

    LTRIM(CAST(('<X>'+REPLACE(url,'utm_source=' ,'</X><X>')+'</X>') AS XML).value('(/X)[2]', 'VARCHAR(128)'))

,'&' ,'</X><X>')+'</X>') AS XML).value('(/X)[1]', 'VARCHAR(128)'))

,'') as actual,
    source as expected

from data
@dataders dataders added the help wanted Extra attention is needed label Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant