Skip to content

Implement array_distinct function #7289

Closed
@izveigor

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

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