From 2190fb909a4a0b2b93a2d03bec4cb8c90f577186 Mon Sep 17 00:00:00 2001 From: Melissa Vagi Date: Thu, 7 Dec 2023 16:52:58 -0700 Subject: [PATCH] rewrite condition functions section for clarity and accuracy Signed-off-by: Melissa Vagi --- .../helpers/ppl_docs/functions/condition.ts | 4 +- .../helpers/ppl_docs/functions/string.ts | 96 ++++++++++--------- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/public/components/common/helpers/ppl_docs/functions/condition.ts b/public/components/common/helpers/ppl_docs/functions/condition.ts index efee8c6df2..4824b5aa23 100644 --- a/public/components/common/helpers/ppl_docs/functions/condition.ts +++ b/public/components/common/helpers/ppl_docs/functions/condition.ts @@ -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 diff --git a/public/components/common/helpers/ppl_docs/functions/string.ts b/public/components/common/helpers/ppl_docs/functions/string.ts index 47236c8345..1667b6bafd 100644 --- a/public/components/common/helpers/ppl_docs/functions/string.ts +++ b/public/components/common/helpers/ppl_docs/functions/string.ts @@ -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 @@ -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 @@ -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) -> INTEGER +**Function signature:** \`LENGTH(STRING) -> 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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