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 when grouping with more than one variable #21

Closed
svkohler opened this issue Oct 2, 2024 · 2 comments · Fixed by #22
Closed

Bug when grouping with more than one variable #21

svkohler opened this issue Oct 2, 2024 · 2 comments · Fixed by #22
Labels
bug Something isn't working

Comments

@svkohler
Copy link

svkohler commented Oct 2, 2024

Example:

When compiling this:

coefficients as (

    select * from {{
      dbt_linreg.ols(
        table='kunde_umsatz_pre_and_post',
        endog='Umsatz',
        exog=['VarianteID', 'Umsatzvorperiode'],
        group_by=['TrancheID', 'MandantID'],
        format='long',
        format_options={'round': 5},
      )
    }}

)

one gets following, see how there is a missing leading whitespace in front of the "and" keyword of the join condition:

(...)
inner join _dbt_linreg_stderrs
on
  b.gb1 = _dbt_linreg_stderrs.gb1and
  b.gb2 = _dbt_linreg_stderrs.gb2
union all
select
  
  b.gb1 as TrancheID,
  b.gb2 as MandantID,
  'Umsatzvorperiode' as variable_name,
  round(x2_coef, 5) as coefficient,
  round(x2_stderr, 5) as standard_error,
  round(x2_coef/x2_stderr, 5) as t_statistic
from _dbt_linreg_final_coefs as b

inner join _dbt_linreg_stderrs
on
  b.gb1 = _dbt_linreg_stderrs.gb1and
  b.gb2 = _dbt_linreg_stderrs.gb2)

One can fix this easily by modifying line 224 of utils.py from:

{%- if not loop.last -%}

to:

 {% if not loop.last -%}
@dwreeves
Copy link
Owner

dwreeves commented Oct 2, 2024

Ahhh! Sorry about that. Good catch on this. 🤦 Should be a quick fix. I'll have a new prerelease version out in the next hour.

Thanks for reporting this issue and for using this library!

@dwreeves
Copy link
Owner

dwreeves commented Oct 2, 2024

@svkohler Thanks again for the report. Updating to the latest version, 0.2.6, will fix the issue:

packages:
  - package: "dwreeves/dbt_linreg"
    version: "0.2.6"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants