Giter Club home page Giter Club logo

Comments (4)

clausherther avatar clausherther commented on May 28, 2024

Hi @swanderz ! That is indeed a bit obtuse. The idea was to be able to test grouped expressions across multiple models. So, say you wanted to test counts by order_date across two models, you could group on order_date. And unfortunately, I don't think this group_by feature is actually used by any of the expectations in this package (yet), so there's no good example, although I use equal_expression directly in one of my project this way.

Rather than conditionally grouping when there is a group_by being passed, I simply always group the expression. The default is simply a string col which acts as a dummy grouping variable. This works fine on all the platforms I've been testing.
However, if T-SQL barfs on this, you could probably override get_select (which is already an adapter macro) and only actually group when there is a non-default grouping value. I'd also be happy to help update the default version to be more explicit when there is no grouping. Does that make sense?

from dbt-expectations.

clausherther avatar clausherther commented on May 28, 2024

Just looking through the code again, I also use this fake column to join the two expression results. So, if there are no columns to group by and you just have two scalar results, like counts for example, I can still join and compare the two without having to change the join type to a cross join.

a.col_{{ i }} = b.col_{{ i }} {% if not loop.last %}and{% endif %}

from dbt-expectations.

clausherther avatar clausherther commented on May 28, 2024

@swanderz take a look at #63 to see if that makes more sense. It's just a quick take on making this more explicit. Btw, there are a couple of direct integration tests against equal_expression that take advantage of group_by.

Does a cross join b work in T-SQL, or do you do a, b there?

from dbt-expectations.

b-per avatar b-per commented on May 28, 2024

In T-SQL a cross join b should work fine, yes

from dbt-expectations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.