Skip to content

Commit ac23bbc

Browse files
authored
Fix Functions.md heading for text functions (#1479)
1 parent a2d5398 commit ac23bbc

File tree

1 file changed

+125
-125
lines changed

1 file changed

+125
-125
lines changed

docs/wiki/documentation/Functions.md

Lines changed: 125 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ CHAR_LENGTH(null) -- `null`
2222
CHAR_LENGTH(missing) -- `null` (also returns `null`)
2323
```
2424

25+
26+
### BIT_LENGTH -- since v0.10.0
27+
28+
Returns the number of bits in the input string.
29+
30+
Signature
31+
: `BIT_LENGTH: String —> Int`
32+
33+
Header
34+
: `BIT_LENGTH(str)`
35+
36+
Examples
37+
:
38+
39+
```sql
40+
bit_length('jose') -- 32
41+
```
42+
2543
### CAST -- since v0.1.0
2644

2745
Given a value and a target data type, attempt to coerce the value to the target data type.
@@ -652,6 +670,90 @@ NULLIF(null, null) -- null
652670
NULLIF(missing, null) -- null
653671
NULLIF(missing, missing) -- null
654672
```
673+
674+
### OCTET_LENGTH -- since v0.10.0
675+
676+
Returns the number of bytes in the input string.
677+
678+
Signature
679+
: `OCTET_LENGTH: String —> Int`
680+
681+
Header
682+
: `OCTET_LENGTH(str)`
683+
684+
Examples
685+
:
686+
687+
```sql
688+
octet_length('jose') -- 4
689+
```
690+
691+
### OVERLAY -- since v0.10.0
692+
693+
OVERLAY modifies a string argument by replacing a given substring of the string, which is specified by a given numeric
694+
starting position and a given numeric length, with another string (called the replacement string). When the length of
695+
the substring is zero, nothing is removed from the original string and the string returned by the
696+
function is the result of inserting the replacement string into the original string at the starting position.
697+
698+
Signature
699+
: `OVERLAY: String, String, Int —> String`
700+
701+
Header
702+
: `OVERLAY(str1 PLACING str2 FROM pos)`
703+
704+
Signature
705+
: `OVERLAY: String, String, Int, Int —> String`
706+
707+
Header
708+
: `OVERLAY(str1 PLACING str2 FROM pos FOR for)`
709+
710+
Examples
711+
:
712+
713+
```sql
714+
overlay('hello' placing '' from 1) -- "hello
715+
overlay('hello' placing '' from 2 for 3) -- "ho
716+
overlay('hello' placing '' from 2 for 4) -- "h
717+
overlay('hello' placing 'XX' from 1) -- "XXllo
718+
overlay('hello' placing 'XX' from 1 for 3) -- "XXlo
719+
overlay('hello' placing 'XX' from 1 for 1) -- "XXello
720+
overlay('hello' placing 'XX' from 1 for 100) -- "XX
721+
overlay('hello' placing 'XX' from 1 for 0) -- "XXhello
722+
overlay('hello' placing 'XX' from 7) -- "helloXX
723+
overlay('hello' placing 'XX' from 100 for 100) -- "helloXX
724+
overlay('hello' placing 'XX' from 2 for 1) -- "hXXllo
725+
overlay('hello' placing 'XX' from 2 for 3) -- "hXXo
726+
```
727+
728+
### POSITION -- since v0.10.0
729+
730+
Position determines the first position (counting from 1), if any, at which one string, str1, occurs within
731+
another, str2. If str1 is of length zero, then it occurs at position 1 (one) for any value of str2. If str1
732+
does not occur in str2, then zero is returned. The declared type of a <position expression> is exact numeric
733+
734+
Signature
735+
: `POSITION: String, String —> Int`
736+
737+
Header
738+
: `POSITION(str1 IN str2)`
739+
740+
Header
741+
: `POSITION(str1, str2)`
742+
743+
Examples
744+
:
745+
746+
```sql
747+
position('foo' in 'hello') -- 0
748+
position('' in 'hello') -- 1
749+
position('h' in 'hello') -- 1
750+
position('o' in 'hello') -- 5
751+
position('ll' in 'hello') -- 3
752+
position('lo' in 'hello') -- 4
753+
position('hello' in 'hello') -- 1
754+
position('xx' in 'xxyyxxyy') -- 1
755+
position('yy' in 'xxyyxxyy') -- 3
756+
```
655757

656758
### SUBSTRING -- since v0.1.0
657759

@@ -693,6 +795,29 @@ SUBSTRING("1", 1, 0) -- ""
693795
SUBSTRING("1", -4, 0) -- ""
694796
SUBSTRING("1234", 10, 10) -- ""
695797
```
798+
799+
### TEXT_REPLACE -- since v0.10.0
800+
801+
In `string`, replaces all occurrences of substring `from` with another string `to`.
802+
803+
Signature
804+
: `TEXT_REPLACE: String, String, String -> String`
805+
806+
Header
807+
: `TEXT_REPLACE(string, from, to)`
808+
809+
Examples
810+
:
811+
812+
```sql
813+
text_replace('abcdefabcdef', 'cd', 'XX') -- 'abXXefabXXef'
814+
text_replace('abcdefabcdef', 'xyz', 'XX') -- 'abcdefabcdef'
815+
text_replace('abcdefabcdef', 'defab', '') -- 'abccdef'
816+
text_replace('abcabcabcdef', 'abcabc', 'XXX') -- 'XXXabcdef'
817+
text_replace('abcabcabcdef', '', 'X') -- 'XaXbXcXaXbXcXaXbXcXdXeXfX'
818+
text_replace('', 'abc', 'XX') -- ''
819+
text_replace('', '', 'XX') -- 'XX'
820+
```
696821

697822
### TO_STRING -- since v0.1.0
698823

@@ -1210,131 +1335,6 @@ pow(`nan`, 1) = `nan`
12101335
pow(1, `+inf`) = `nan`
12111336
```
12121337

1213-
### BIT_LENGTH -- since v0.10.0
1214-
1215-
Returns the number of bits in the input string.
1216-
1217-
Signature
1218-
: `BIT_LENGTH: String —> Int`
1219-
1220-
Header
1221-
: `BIT_LENGTH(str)`
1222-
1223-
Examples
1224-
:
1225-
1226-
```sql
1227-
bit_length('jose') -- 32
1228-
```
1229-
1230-
### OCTET_LENGTH -- since v0.10.0
1231-
1232-
Returns the number of bytes in the input string.
1233-
1234-
Signature
1235-
: `OCTET_LENGTH: String —> Int`
1236-
1237-
Header
1238-
: `OCTET_LENGTH(str)`
1239-
1240-
Examples
1241-
:
1242-
1243-
```sql
1244-
octet_length('jose') -- 4
1245-
```
1246-
1247-
### POSITION -- since v0.10.0
1248-
1249-
Position determines the first position (counting from 1), if any, at which one string, str1, occurs within
1250-
another, str2. If str1 is of length zero, then it occurs at position 1 (one) for any value of str2. If str1
1251-
does not occur in str2, then zero is returned. The declared type of a <position expression> is exact numeric
1252-
1253-
Signature
1254-
: `POSITION: String, String —> Int`
1255-
1256-
Header
1257-
: `POSITION(str1 IN str2)`
1258-
1259-
Header
1260-
: `POSITION(str1, str2)`
1261-
1262-
Examples
1263-
:
1264-
1265-
```sql
1266-
position('foo' in 'hello') -- 0
1267-
position('' in 'hello') -- 1
1268-
position('h' in 'hello') -- 1
1269-
position('o' in 'hello') -- 5
1270-
position('ll' in 'hello') -- 3
1271-
position('lo' in 'hello') -- 4
1272-
position('hello' in 'hello') -- 1
1273-
position('xx' in 'xxyyxxyy') -- 1
1274-
position('yy' in 'xxyyxxyy') -- 3
1275-
```
1276-
1277-
1278-
### OVERLAY -- since v0.10.0
1279-
1280-
OVERLAY modifies a string argument by replacing a given substring of the string, which is specified by a given numeric
1281-
starting position and a given numeric length, with another string (called the replacement string). When the length of
1282-
the substring is zero, nothing is removed from the original string and the string returned by the
1283-
function is the result of inserting the replacement string into the original string at the starting position.
1284-
1285-
Signature
1286-
: `OVERLAY: String, String, Int —> String`
1287-
1288-
Header
1289-
: `OVERLAY(str1 PLACING str2 FROM pos)`
1290-
1291-
Signature
1292-
: `OVERLAY: String, String, Int, Int —> String`
1293-
1294-
Header
1295-
: `OVERLAY(str1 PLACING str2 FROM pos FOR for)`
1296-
1297-
Examples
1298-
:
1299-
1300-
```sql
1301-
overlay('hello' placing '' from 1) -- "hello
1302-
overlay('hello' placing '' from 2 for 3) -- "ho
1303-
overlay('hello' placing '' from 2 for 4) -- "h
1304-
overlay('hello' placing 'XX' from 1) -- "XXllo
1305-
overlay('hello' placing 'XX' from 1 for 3) -- "XXlo
1306-
overlay('hello' placing 'XX' from 1 for 1) -- "XXello
1307-
overlay('hello' placing 'XX' from 1 for 100) -- "XX
1308-
overlay('hello' placing 'XX' from 1 for 0) -- "XXhello
1309-
overlay('hello' placing 'XX' from 7) -- "helloXX
1310-
overlay('hello' placing 'XX' from 100 for 100) -- "helloXX
1311-
overlay('hello' placing 'XX' from 2 for 1) -- "hXXllo
1312-
overlay('hello' placing 'XX' from 2 for 3) -- "hXXo
1313-
```
1314-
1315-
### TEXT_REPLACE -- since v0.10.0
1316-
1317-
In `string`, replaces all occurrences of substring `from` with another string `to`.
1318-
1319-
Signature
1320-
: `TEXT_REPLACE: String, String, String -> String`
1321-
1322-
Header
1323-
: `TEXT_REPLACE(string, from, to)`
1324-
1325-
Examples
1326-
:
1327-
1328-
```sql
1329-
text_replace('abcdefabcdef', 'cd', 'XX') -- 'abXXefabXXef'
1330-
text_replace('abcdefabcdef', 'xyz', 'XX') -- 'abcdefabcdef'
1331-
text_replace('abcdefabcdef', 'defab', '') -- 'abccdef'
1332-
text_replace('abcabcabcdef', 'abcabc', 'XXX') -- 'XXXabcdef'
1333-
text_replace('abcabcabcdef', '', 'X') -- 'XaXbXcXaXbXcXaXbXcXdXeXfX'
1334-
text_replace('', 'abc', 'XX') -- ''
1335-
text_replace('', '', 'XX') -- 'XX'
1336-
```
1337-
13381338
<!--
13391339
This is the template for writing documentations for an PartiQL built-in function.
13401340

0 commit comments

Comments
 (0)