Skip to content

Implement array_distinct function #7289

Closed

Description

@izveigor

Is your feature request related to a problem or challenge?

Summary

Characteristic Description
Function name: array_distinct
Aliases: list_distinct
Original function?: No
Function Description: DuckDB: Removes all duplicates and NULLs from a list. Does not preserve the original order.
Azure DataBricks: Removes duplicate values from array.
SQL Spark: Return distinct values from the array after removing duplicates.
Sources: Concept DuckDB Azure Spark

Examples:

D select array_distinct([1, 3, 2, 3, 1, 2, 4]);
┌──────────────────────────────────────────────────────┐
│ array_distinct(main.list_value(1, 3, 2, 3, 1, 2, 4)) │
│                       int32[]                        │
├──────────────────────────────────────────────────────┤
│ [4, 2, 3, 1]                                         │
└──────────────────────────────────────────────────────┘
D select array_distinct(['a', 'b', 'c', 'd']);
┌─────────────────────────────────────────────────────┐
│ array_distinct(main.list_value('a', 'b', 'c', 'd')) │
│                      varchar[]                      │
├─────────────────────────────────────────────────────┤
│ [b, d, c, a]                                        │
└─────────────────────────────────────────────────────┘

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Activity

  1. my-vegetable-has-exploded commented on Nov 13, 2023

    @my-vegetable-has-exploded
    Contributor

    May I try this issue?

  2. my-vegetable-has-exploded commented on Nov 19, 2023

    @my-vegetable-has-exploded
    Contributor

    Shall we preserve the original order here?

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

Metadata

Metadata

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