functions: add char function #7486
Conversation
dbms/src/Functions/FunctionsCoding.h
Outdated
There was a problem hiding this comment.
It isn't an "IP coding function".
Let's move to another test file.
There was a problem hiding this comment.
Does it really have the same behaviour? What about numbers out of ASCII range?
There was a problem hiding this comment.
I gave up implementing the same Behavior as mysql when number out of ASCII range.
It could return multiply characters, I think it's unnecessary and I don't know the internal implementation.
mysql> select char(2221111111111);
+---------------------+
| char(2221111111111) |
+---------------------+
| $��� |
+---------------------+
1 row in set (0.00 sec)
So I just took the first byte. It's easy to make it done by Column and easy to know the results.
dbms/src/Functions/FunctionsCoding.h
Outdated
There was a problem hiding this comment.
Virtual call in a loop.
dbms/src/Functions/FunctionsCoding.h
Outdated
There was a problem hiding this comment.
Style: ++row instead of row ++.
dbms/src/Functions/FunctionsCoding.h
Outdated
|
Undo cn documents(Need |
286ee5f to
538b77c
Compare
| # Encoding functions | ||
|
|
||
| ## char | ||
| Accepts multiple arguments of `Number` types. Returns a string, each char of the results corresponds to the ascii character of the input numbers. It'll cast the first byte from the number, if the byte overflows the range of ascii(which is 127), it returns an unrecognized character(�). |
There was a problem hiding this comment.
We can construct UTF-8 string with this function. It's not limited for ASCII. I will test...
|
|
||
| for (size_t row = 0; row < rows; ++row) | ||
| { | ||
| out_vec[row * size_per_row + column_idx] = static_cast<char>(src_data_concrete->getInt(row)); |
There was a problem hiding this comment.
Ok. BTW, it's in question what variant of loop is faster - this one or permuted.
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):
Short description (up to few sentences):
char function like mysql. But Behavior is not exactly the same.
Our users who used MySQL a lot said to me they really need it in ClickHouse, so I create this PR.