Skip to content

Commit

Permalink
rewrite condition functions section for clarity and accuracy
Browse files Browse the repository at this point in the history
Signed-off-by: Melissa Vagi <vagimeli@amazon.com>
  • Loading branch information
vagimeli committed Dec 7, 2023
1 parent b59d8d9 commit 2190fb9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const conditionFunction = `## Condition
### Condition functions
PPL functions use the search capabilities of the OpenSearch engine. However, these functions don't execute directly within the OpenSearch plugin's memory. Instead, they facilitte the global filtering of query results based on specific conditions, such as a \`WHERE\` or \`HAVING\` clause.
PPL functions use the search capabilities of the OpenSearch engine. However, these functions don't execute directly within the OpenSearch plugin's memory. Instead, they facilitate the global filtering of query results based on specific conditions, such as a \`WHERE\` or \`HAVING\` clause.
The following sections describe the \`datetime\` PPL functions.
The following sections describe the condition PPL functions.
### ISNULL
Expand Down
96 changes: 50 additions & 46 deletions public/components/common/helpers/ppl_docs/functions/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@
export const stringFunction = `## String
---
### String functions
PPL functions use the search capabilities of the OpenSearch engine. However, these functions don't execute directly within the OpenSearch plugin's memory. Instead, they facilitate the global filtering of query results based on specific conditions, such as a \`WHERE\` or \`HAVING\` clause.
The following sections describe the string functions.
### CONCAT
\`CONCAT(str1, str2)\` returns \`str1\` and \`str\` concatenated strings.
The \`CONCAT(str1, str2)\` function returns \`str1\` and \`str\` concatenated strings.
Argument type: STRING, STRING
**Argument type:** \`STRING, STRING\`
Return type: STRING
**Return type:** \`STRING\`
**Example**
#### Example
os> source=people | eval \`CONCAT('hello', 'world')\` = CONCAT('hello', 'world') | fields \`CONCAT('hello', 'world')\`
fetched rows / total rows = 1/1
Expand All @@ -26,13 +32,13 @@ Return type: STRING
### CONCAT\_WS
\`CONCAT\_WS(sep, str1, str2)\` is a function that concatenates two strings together, using \`sep\` as a separator between them.
The \`CONCAT\_WS(sep, str1, str2)\` function concatenates two strings together, using \`sep\` as a separator between them.
Argument type: STRING, STRING, STRING
**Argument type:** \`STRING, STRING, STRING\`
Return type: STRING
**Return type:** \`STRING\`
**Example**
#### Example
os> source=people | eval \`CONCAT_WS(',', 'hello', 'world')\` = CONCAT_WS(',', 'hello', 'world') | fields \`CONCAT_WS(',', 'hello', 'world')\`
fetched rows / total rows = 1/1
Expand All @@ -44,15 +50,15 @@ Return type: STRING
### LENGTH
\`length(str)\` is a function that returns the length of a string, measured in number of bytes.
The \`length(str)\` function returns the length of a string, measured in number of bytes.
Specification: LENGTH(STRING) -&gt; INTEGER
**Function signature:** \`LENGTH(STRING) -&gt; INTEGER\`
Argument type: STRING
**Argument type:** \`STRING\`
Return type: INTEGER
**Return type:** \`INTEGER\`
**Example**
#### Example
os> source=people | eval \`LENGTH('helloworld')\` = LENGTH('helloworld') | fields \`LENGTH('helloworld')\`
fetched rows / total rows = 1/1
Expand All @@ -64,14 +70,12 @@ Return type: INTEGER
### LIKE
\`like(string, PATTERN)\` is a function that returns \`true\` if the string matches the \`PATTERN\` value.
The following two wildcards are commonly used with the \`like\` operator:
The \`like(string, PATTERN)\` function returns \`true\` if the string matches the \`PATTERN\` value. The following two wildcards are commonly used with the \`like\` operator:
- \`%\`: A percent sign represents zero, one, or multiple characters.
- \`_\`: An underscore represents a single character.
**Example**
#### Example
os> source=people | eval \`LIKE('hello world', '_ello%')\` = LIKE('hello world', '_ello%') | fields \`LIKE('hello world', '_ello%')\`
fetched rows / total rows = 1/1
Expand All @@ -83,13 +87,13 @@ The following two wildcards are commonly used with the \`like\` operator:
### LOWER
\`lower(string)\` is a function that converts a string to lowercase.
The \`lower(string)\` function converts a string to lowercase.
Argument type: STRING
**Argument type:** \`STRING\`
Return type: STRING
**Return type:** \`STRING\`
**Example**
#### Example
os> source=people | eval \`LOWER('helloworld')\` = LOWER('helloworld'), \`LOWER('HELLOWORLD')\` = LOWER('HELLOWORLD') | fields \`LOWER('helloworld')\`, \`LOWER('HELLOWORLD')\`
fetched rows / total rows = 1/1
Expand All @@ -101,13 +105,13 @@ Return type: STRING
### LTRIM
\`ltrim(str)\` is a function that trims leading space characters from a string.
The \`ltrim(str)\` function trims leading space characters from a string.
Argument type: STRING
**Argument type:** \`STRING\`
Return type: STRING
**Return type:** \`STRING\`
**Example**
#### Example
os> source=people | eval \`LTRIM(' hello')\` = LTRIM(' hello'), \`LTRIM('hello ')\` = LTRIM('hello ') | fields \`LTRIM(' hello')\`, \`LTRIM('hello ')\`
fetched rows / total rows = 1/1
Expand All @@ -119,13 +123,13 @@ Return type: STRING
### RIGHT
\`right(str, len)\` is a function that returns the rightmost \`len\` characters from a \`str\` value. \`NULL\` is returned if any argument is null.
The \`right(str, len)\` function returns the rightmost \`len\` characters from a \`str\` value. \`NULL\` is returned if any argument is null.
Argument type: STRING, INTEGER
**Argument type:** \`STRING, INTEGER\`
Return type: STRING
**Return type:** \`STRING\`
**Example**
#### Example
os> source=people | eval \`RIGHT('helloworld', 5)\` = RIGHT('helloworld', 5), \`RIGHT('HELLOWORLD', 0)\` = RIGHT('HELLOWORLD', 0) | fields \`RIGHT('helloworld', 5)\`, \`RIGHT('HELLOWORLD', 0)\`
fetched rows / total rows = 1/1
Expand All @@ -137,13 +141,13 @@ Return type: STRING
### RTRIM
\`rtrim(str)\` is a function that trims trailing space characters from a string.
The \`rtrim(str)\` function trims trailing space characters from a string.
Argument type: STRING
**Argument type:** \`STRING\`
Return type: STRING
**Return type:** \`STRING\`
**Example**
#### Example
os> source=people | eval \`RTRIM(' hello')\` = RTRIM(' hello'), \`RTRIM('hello ')\` = RTRIM('hello ') | fields \`RTRIM(' hello')\`, \`RTRIM('hello ')\`
fetched rows / total rows = 1/1
Expand All @@ -155,15 +159,15 @@ Return type: STRING
### SUBSTRING
\`substring(str, start)\` or \`substring(str, start, length)\` is a function that returns a substring of the input string \`str\`. If \`length\` is not specified, the function returns the entire string from the \`start\` index.
The \`substring(str, start)\` or \`substring(str, start, length)\`function returns a substring of the input string \`str\`. If \`length\` is not specified, the function returns the entire string from the \`start\` index.
Argument type: STRING, INTEGER, INTEGER
**Argument type:** \`STRING, INTEGER, INTEGER\`
Return type: STRING
**Return type:** \`STRING\`
Synonyms: SUBSTR
**Synonyms:** \`SUBSTR\`
**Example**
#### Example
os> source=people | eval \`SUBSTRING('helloworld', 5)\` = SUBSTRING('helloworld', 5), \`SUBSTRING('helloworld', 5, 3)\` = SUBSTRING('helloworld', 5, 3) | fields \`SUBSTRING('helloworld', 5)\`, \`SUBSTRING('helloworld', 5, 3)\`
fetched rows / total rows = 1/1
Expand All @@ -175,13 +179,13 @@ Synonyms: SUBSTR
### TRIM
\`trim\` is a function used to remove leading and trailing white space from a string.
The \`trim\` function removes leading and trailing white space from a string.
Argument Type: STRING
**Argument type:** \`STRING\`
Return type: STRING
**Return type:** \`STRING\`
**Example**
#### Example
os> source=people | eval \`TRIM(' hello')\` = TRIM(' hello'), \`TRIM('hello ')\` = TRIM('hello ') | fields \`TRIM(' hello')\`, \`TRIM('hello ')\`
fetched rows / total rows = 1/1
Expand All @@ -193,13 +197,13 @@ Return type: STRING
### UPPER
\`upper(string)\` is a function that converts a string to uppercase.
The \`upper(string)\` function converts a string to uppercase.
Argument type: STRING
**Argument type:** \`STRING\`
Return type: STRING
**Return type:** \`STRING\`
**Example**
#### Example
os> source=people | eval \`UPPER('helloworld')\` = UPPER('helloworld'), \`UPPER('HELLOWORLD')\` = UPPER('HELLOWORLD') | fields \`UPPER('helloworld')\`, \`UPPER('HELLOWORLD')\`
fetched rows / total rows = 1/1
Expand Down

0 comments on commit 2190fb9

Please sign in to comment.