mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Add convenience alias byteSlice for substring
This commit is contained in:
parent
fe50b5871b
commit
e02c083e60
@ -167,6 +167,10 @@ Result:
|
||||
└──────────────────────────────────────────┴───────────────────────────────┘
|
||||
```
|
||||
|
||||
## byteSlice(s, offset, length)
|
||||
|
||||
See function [substring](string-functions.md#substring).
|
||||
|
||||
## bitTest
|
||||
|
||||
Takes any integer and converts it into [binary form](https://en.wikipedia.org/wiki/Binary_number), returns the value of a bit at specified position. The countdown starts from 0 from the right to the left.
|
||||
|
@ -558,6 +558,7 @@ substring(s, offset[, length])
|
||||
Alias:
|
||||
- `substr`
|
||||
- `mid`
|
||||
- `byteSlice`
|
||||
|
||||
**Arguments**
|
||||
|
||||
|
@ -189,6 +189,7 @@ REGISTER_FUNCTION(Substring)
|
||||
factory.registerFunction<FunctionSubstring<false>>({}, FunctionFactory::CaseInsensitive);
|
||||
factory.registerAlias("substr", "substring", FunctionFactory::CaseInsensitive); // MySQL alias
|
||||
factory.registerAlias("mid", "substring", FunctionFactory::CaseInsensitive); /// MySQL alias
|
||||
factory.registerAlias("byteSlice", "substring", FunctionFactory::CaseInsensitive); /// resembles PostgreSQL's get_byte function, similar to ClickHouse's bitSlice
|
||||
|
||||
factory.registerFunction<FunctionSubstring<true>>({}, FunctionFactory::CaseSensitive);
|
||||
}
|
||||
|
@ -170,4 +170,6 @@ g
|
||||
|
||||
|
||||
|
||||
UBSAN bug
|
||||
-- UBSAN bug
|
||||
-- Alias
|
||||
el
|
||||
|
@ -132,7 +132,7 @@ SELECT substring(s, l, r) FROM t;
|
||||
|
||||
DROP table if exists t;
|
||||
|
||||
SELECT 'UBSAN bug';
|
||||
SELECT '-- UBSAN bug';l
|
||||
|
||||
/** NOTE: The behaviour of substring and substringUTF8 is inconsistent when negative offset is greater than string size:
|
||||
* substring:
|
||||
@ -144,3 +144,6 @@ SELECT 'UBSAN bug';
|
||||
* This may be subject for change.
|
||||
*/
|
||||
SELECT substringUTF8('hello, пÑ<C2BF>ивеÑ<C2B5>', -9223372036854775808, number) FROM numbers(16) FORMAT Null;
|
||||
|
||||
SELECT '-- Alias';
|
||||
SELECT byteSlice('hello', 2, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user