Skip to content

group not working as intended with take #421

Closed

Description

@max-sixty

Possibly we need to implement #420 given our plan of how to implement this query? Though in the meantime, should this raise an error rather than ignoring group?

from employees
group role (
  sort join_date  # taken from above
  take 1
)
SELECT
  employees.*
FROM
  employees
ORDER BY
  join_date
LIMIT
  1

Activity

  1. added
    bug
    on Apr 26, 2022
  2. aljazerzen commented on Apr 28, 2022

    @aljazerzen
    Member

    I believe this now throws an error:

    from employees
    group role (
      sort join_date  # taken from above
      take 1
    )
    
    Error: transform `Take` is not allowed within group context
    

    It's also missing the span and pretty formatting, but eventually this should compile to DISTINCT anyway.

  3. max-sixty commented on Apr 29, 2022

    @max-sixty
    MemberAuthor

    OK cool — FYI it doesn't throw an error on main, but maybe on the proposed PR

  4. aljazerzen commented on Apr 29, 2022

    @aljazerzen
    Member

    True that, I merged "window functions PR" so now it should.

  5. max-sixty commented on Apr 29, 2022

    @max-sixty
    MemberAuthor

    Wonderful, confirmed:
    image

  6. max-sixty commented on May 19, 2022

    @max-sixty
    MemberAuthor

    We now have DISTINCT working!

    We don't have it working in groups though, so we should probably raise an error:

    from employees
    group role (
      sort join_date  # taken from above
      take 1
    )
    SELECT
      DISTINCT employees.*
    FROM
      employees
  7. aljazerzen commented on May 19, 2022

    @aljazerzen
    Member

    This is not easy to do with our current compiler setup. Will instead try to hurry up with making this work.

    But I've added this error message:

    from employees
    group aaa (
      take 1..2
    )
    Error:
       ╭─[-:3:3]
       │
     3 │   take 1..2
       ·   ────┬────
       ·       ╰────── `take` within `group` currently only supports argument `1`
       ·
       · Help: For now, you can derive a row number within a group and do a filter on that.
    ───╯
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcompiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions