Skip to content

added bitmapTransform#7598

Merged
alexey-milovidov merged 6 commits intoClickHouse:masterfrom
infinivision:bitmap_replace
Nov 4, 2019
Merged

added bitmapTransform#7598
alexey-milovidov merged 6 commits intoClickHouse:masterfrom
infinivision:bitmap_replace

Conversation

@yuzhichang
Copy link
Contributor

@yuzhichang yuzhichang commented Nov 3, 2019

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

For changelog. Remove if this is non-significant change.

Category (leave one):

  • New Feature

bitmapTransform

Transform an array of values in a bitmap to another array of values, the result is a new bitmap.

bitmapTransform(bitmap, from_array, to_array)

Parameters

  • bitmap – bitmap object.
  • from_array – UInt32 array. For idx in range [0, from_array.size()), if bitmap contains from_array[idx], then replace it with to_array[idx]. Note that the result depends on array ordering if there are common elements between from_array and to_array.
  • to_array – UInt32 array, its size shall be the same to from_array.

Example

SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), cast([5,999,2] as Array(UInt32)), cast([2,888,20] as Array(UInt32)))) AS res
┌─res───────────────────┐
│ [1,3,4,6,7,8,9,10,20] │
└───────────────────────┘

@amosbird
Copy link
Collaborator

amosbird commented Nov 3, 2019

I would name it bitmapTransform as columns are very much immutable at SQL level.

@alexey-milovidov
Copy link
Member

+1. It will be also more consistent with transform function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result here is a bit surprising, especially since result depends on array ordering, might be worth explicit mention in docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in doc.

@yuzhichang yuzhichang changed the title added bitmapReplace added bitmapTransform Nov 4, 2019
@yuzhichang
Copy link
Contributor Author

I would name it bitmapTransform as columns are very much immutable at SQL level.

Done as you suggested.

@alexey-milovidov alexey-milovidov merged commit 6a871f5 into ClickHouse:master Nov 4, 2019
@CurtizJ CurtizJ added the pr-feature Pull request with new product feature label Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants