ClickHouse
ClickHouse copied to clipboard
Add `arrayUnion` function
Hey @rschu1ze, I'd like to try fixing this issue. Can you assign it to me?
Cool, please go ahead, thanks.
@rschu1ze Just wanted to confirm this before I start working to not miss anything.
Initial Plan:
- Add an
arrayUnion.cpp
file undersrc/Functions/array
& implement the required function - Use the
tests/queries/0_stateless/add-test
script to generate a.sql
&.reference
file - Add tests in the generated
.sql
file & then update the reference file with:clickhouse-client --multiquery < 0xxxx_arrayUnion.sql > 0xxxx_arrayUnion.reference
- Update
docs/en/sql-reference/functions/array-functions.md
- Update
utils/check-style/aspell-ignore/en/aspell-dict.txt
@tinfoil-knight The new function arrayUnion
is conceptually similar to the existing function arrayIntersect
. We should avoid to re-implement logic. Therefore, I'd suggest as first step to check src/Functions/array/arrayIntersect.cpp
(possibly step through it using a debugger) which has a well-optimized implementation. As far as I see, most of the existing code also applies to arrayUnion
and we only need to templatize FunctionArrayIntersect::execute
(e.g. add a new template parameter bool intersect
to distinguish intersect
and union
cases) and add a path under an if constexpr
to it.
The other steps look good!
@rschu1ze I'll work on this one
@Blargian That's nice, I assigned you. Please ping me if you like me to have a look.
@Blargian Are you still working on this? If not, I'd like to give it a shot.
@petern48 please go ahead! I got distracted with another project.