Giter VIP home page Giter VIP logo

Comments (5)

max-sixty avatar max-sixty commented on June 14, 2024

Thanks @PrettyWood !

Am I correct in thinking that we do want DISTINCT ON in postgres, but there's a bug in ignoring the take 2 transform?

from prql.

PrettyWood avatar PrettyWood commented on June 14, 2024

I guess so

from prql.

aljazerzen avatar aljazerzen commented on June 14, 2024

No, we don't want DISTINCT ON since that will pick only the first item in each GROUP BY partition.

The correct behavior would be to pick first two items in each partition. In SQL, this is only achievable by using ROW_NUMBER() and WHERE.

This is the problem here: https://github.com/prql/PRQL/blob/main/prqlc/prql-compiler/src/sql/srq/preprocess.rs#L172-L177

  • we are checking if we should take_only_first,
  • we correctly apply this condition to DISTINCT,
  • we don't apply this condition to DISTINCT ON <-- this is the bug

from prql.

aljazerzen avatar aljazerzen commented on June 14, 2024

Oh, I didn't notice, you've opened a PR already.

from prql.

max-sixty avatar max-sixty commented on June 14, 2024

Oh, I didn't notice, you've opened a PR already.

Yeah and also realized my suggestion was wrong 😄

from prql.

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.