Skip to content

Support mode in Aggregation function #12248

Closed

Description

@Weijun-H

Is your feature request related to a problem or challenge?

The most frequent value.

Describe the solution you'd like

D SELECT mode(col) FROM VALUES ([1, 2]), ([1, 2]), ([2, 3]) AS tab(col);
┌───────────┐
│ mode(col) │
│  varchar  │
├───────────┤
│ [1, 2]    │
└───────────┘

-- The function returns either 1 or 2, but not 3
> SELECT mode(col) FROM VALUES (1), (1), (2), (2), (3) AS tab(col);
 1

> SELECT mode(col) FROM VALUES (NULL), (NULL) AS tab(col);
 NULL

Describe alternatives you've considered

No response

Additional context

https://duckdb.org/docs/sql/functions/aggregates#modex
https://docs.databricks.com/en/sql/language-manual/functions/mode.html

Activity

  1. s5dsn-eqee commented on Aug 30, 2024

    @s5dsn-eqee
    Contributor

    take

  2. s5dsn-eqee commented on Sep 7, 2024

    @s5dsn-eqee
    Contributor

    Done for primitive/float types, working on bytes/views.

  3. alamb commented on Sep 9, 2024

    @alamb
    Contributor

    Given #12357 we may want to move this function to some other repo rather than the core

  4. alamb commented on Sep 16, 2024

    @alamb
    Contributor

    Suggestion: #12254 (comment)

  5. s5dsn-eqee commented on Sep 23, 2024

    @s5dsn-eqee
    Contributor

    Implemented: mode.rs

  6. alamb commented on Sep 25, 2024

    @alamb
    Contributor

    We are going to implement these in a different repository so closing this ticket to avoid confusion: #12254 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions