diff --git a/docs/user/beyond/partiql.rst b/docs/user/beyond/partiql.rst index 76fec8405d..6a93a55c94 100644 --- a/docs/user/beyond/partiql.rst +++ b/docs/user/beyond/partiql.rst @@ -202,11 +202,11 @@ Selecting top level for object fields, object fields of array value and nested f os> SELECT city, accounts, projects FROM people; fetched rows / total rows = 1/1 - +-----------------------------------------------------+------------+----------------------------------------------------------------------------------------------------------------+ - | city | accounts | projects | - |-----------------------------------------------------+------------+----------------------------------------------------------------------------------------------------------------| - | {'name': 'Seattle', 'location': {'latitude': 10.5}} | {'id': 1} | [{'name': 'AWS Redshift Spectrum querying'},{'name': 'AWS Redshift security'},{'name': 'AWS Aurora security'}] | - +-----------------------------------------------------+------------+----------------------------------------------------------------------------------------------------------------+ + +-----------------------------------------------------+-----------+----------------------------------------------------------------------------------------------------------------+ + | city | accounts | projects | + |-----------------------------------------------------+-----------+----------------------------------------------------------------------------------------------------------------| + | {'name': 'Seattle', 'location': {'latitude': 10.5}} | {'id': 1} | [{'name': 'AWS Redshift Spectrum querying'},{'name': 'AWS Redshift security'},{'name': 'AWS Aurora security'}] | + +-----------------------------------------------------+-----------+----------------------------------------------------------------------------------------------------------------+ Example 2: Selecting Deeper Levels ---------------------------------- @@ -215,11 +215,11 @@ Selecting at deeper levels for object fields of regular value returns inner fiel os> SELECT city.location, city.location.latitude FROM people; fetched rows / total rows = 1/1 - +--------------------+--------------------------+ - | city.location | city.location.latitude | - |--------------------+--------------------------| - | {'latitude': 10.5} | 10.5 | - +--------------------+--------------------------+ + +--------------------+------------------------+ + | city.location | city.location.latitude | + |--------------------+------------------------| + | {'latitude': 10.5} | 10.5 | + +--------------------+------------------------+ For selecting second level for nested fields, please read on and find more details in the following sections. diff --git a/docs/user/dql/aggregations.rst b/docs/user/dql/aggregations.rst index 42db4cdb4f..adf933c09c 100644 --- a/docs/user/dql/aggregations.rst +++ b/docs/user/dql/aggregations.rst @@ -34,12 +34,12 @@ The group by expression could be identifier:: os> SELECT gender, sum(age) FROM accounts GROUP BY gender; fetched rows / total rows = 2/2 - +----------+------------+ - | gender | sum(age) | - |----------+------------| - | F | 28 | - | M | 101 | - +----------+------------+ + +--------+----------+ + | gender | sum(age) | + |--------+----------| + | F | 28 | + | M | 101 | + +--------+----------+ Ordinal @@ -49,12 +49,12 @@ The group by expression could be ordinal:: os> SELECT gender, sum(age) FROM accounts GROUP BY 1; fetched rows / total rows = 2/2 - +----------+------------+ - | gender | sum(age) | - |----------+------------| - | F | 28 | - | M | 101 | - +----------+------------+ + +--------+----------+ + | gender | sum(age) | + |--------+----------| + | F | 28 | + | M | 101 | + +--------+----------+ Expression @@ -64,14 +64,14 @@ The group by expression could be expression:: os> SELECT abs(account_number), sum(age) FROM accounts GROUP BY abs(account_number); fetched rows / total rows = 4/4 - +-----------------------+------------+ - | abs(account_number) | sum(age) | - |-----------------------+------------| - | 1 | 32 | - | 13 | 28 | - | 18 | 33 | - | 6 | 36 | - +-----------------------+------------+ + +---------------------+----------+ + | abs(account_number) | sum(age) | + |---------------------+----------| + | 1 | 32 | + | 13 | 28 | + | 18 | 33 | + | 6 | 36 | + +---------------------+----------+ Aggregation @@ -91,12 +91,12 @@ The aggregation could be used select:: os> SELECT gender, sum(age) FROM accounts GROUP BY gender; fetched rows / total rows = 2/2 - +----------+------------+ - | gender | sum(age) | - |----------+------------| - | F | 28 | - | M | 101 | - +----------+------------+ + +--------+----------+ + | gender | sum(age) | + |--------+----------| + | F | 28 | + | M | 101 | + +--------+----------+ Expression over Aggregation --------------------------- @@ -105,12 +105,12 @@ The aggregation could be used as arguments of expression:: os> SELECT gender, sum(age) * 2 as sum2 FROM accounts GROUP BY gender; fetched rows / total rows = 2/2 - +----------+--------+ - | gender | sum2 | - |----------+--------| - | F | 56 | - | M | 202 | - +----------+--------+ + +--------+------+ + | gender | sum2 | + |--------+------| + | F | 56 | + | M | 202 | + +--------+------+ Expression as argument of Aggregation ------------------------------------- @@ -119,12 +119,12 @@ The aggregation could has expression as arguments:: os> SELECT gender, sum(age * 2) as sum2 FROM accounts GROUP BY gender; fetched rows / total rows = 2/2 - +----------+--------+ - | gender | sum2 | - |----------+--------| - | F | 56 | - | M | 202 | - +----------+--------+ + +--------+------+ + | gender | sum2 | + |--------+------| + | F | 56 | + | M | 202 | + +--------+------+ COUNT Aggregations ------------------ @@ -150,12 +150,12 @@ Example:: os> SELECT gender, count(*) as countV FROM accounts GROUP BY gender; fetched rows / total rows = 2/2 - +----------+----------+ - | gender | countV | - |----------+----------| - | F | 1 | - | M | 3 | - +----------+----------+ + +--------+--------+ + | gender | countV | + |--------+--------| + | F | 1 | + | M | 3 | + +--------+--------+ SUM --- @@ -169,12 +169,12 @@ Example:: os> SELECT gender, sum(age) as sumV FROM accounts GROUP BY gender; fetched rows / total rows = 2/2 - +----------+--------+ - | gender | sumV | - |----------+--------| - | F | 28 | - | M | 101 | - +----------+--------+ + +--------+------+ + | gender | sumV | + |--------+------| + | F | 28 | + | M | 101 | + +--------+------+ AVG --- @@ -188,12 +188,12 @@ Example:: os> SELECT gender, avg(age) as avgV FROM accounts GROUP BY gender; fetched rows / total rows = 2/2 - +----------+--------------------+ - | gender | avgV | - |----------+--------------------| - | F | 28.0 | - | M | 33.666666666666664 | - +----------+--------------------+ + +--------+--------------------+ + | gender | avgV | + |--------+--------------------| + | F | 28.0 | + | M | 33.666666666666664 | + +--------+--------------------+ MAX --- @@ -207,11 +207,11 @@ Example:: os> SELECT max(age) as maxV FROM accounts; fetched rows / total rows = 1/1 - +--------+ - | maxV | - |--------| - | 36 | - +--------+ + +------+ + | maxV | + |------| + | 36 | + +------+ MIN --- @@ -225,11 +225,11 @@ Example:: os> SELECT min(age) as minV FROM accounts; fetched rows / total rows = 1/1 - +--------+ - | minV | - |--------| - | 28 | - +--------+ + +------+ + | minV | + |------| + | 28 | + +------+ VAR_POP ------- @@ -364,11 +364,11 @@ To get the count of distinct values of a field, you can add a keyword ``DISTINCT os> SELECT COUNT(DISTINCT gender), COUNT(gender) FROM accounts; fetched rows / total rows = 1/1 - +--------------------------+-----------------+ - | COUNT(DISTINCT gender) | COUNT(gender) | - |--------------------------+-----------------| - | 2 | 4 | - +--------------------------+-----------------+ + +------------------------+---------------+ + | COUNT(DISTINCT gender) | COUNT(gender) | + |------------------------+---------------| + | 2 | 4 | + +------------------------+---------------+ PERCENTILE or PERCENTILE_APPROX ------------------------------- @@ -382,12 +382,12 @@ Example:: os> SELECT gender, percentile(age, 90) as p90 FROM accounts GROUP BY gender; fetched rows / total rows = 2/2 - +----------+-------+ - | gender | p90 | - |----------+-------| - | F | 28 | - | M | 36 | - +----------+-------+ + +--------+-----+ + | gender | p90 | + |--------+-----| + | F | 28 | + | M | 36 | + +--------+-----+ HAVING Clause ============= @@ -413,11 +413,11 @@ Here is an example for typical use of ``HAVING`` clause:: ... GROUP BY gender ... HAVING sum(age) > 100; fetched rows / total rows = 1/1 - +----------+------------+ - | gender | sum(age) | - |----------+------------| - | M | 101 | - +----------+------------+ + +--------+----------+ + | gender | sum(age) | + |--------+----------| + | M | 101 | + +--------+----------+ Here is another example for using alias in ``HAVING`` condition. Note that if an identifier is ambiguous, for example present both as a select alias and an index field, preference is alias. This means the identifier will be replaced by expression aliased in ``SELECT`` clause:: @@ -427,11 +427,11 @@ Here is another example for using alias in ``HAVING`` condition. Note that if an ... GROUP BY gender ... HAVING s > 100; fetched rows / total rows = 1/1 - +----------+-----+ - | gender | s | - |----------+-----| - | M | 101 | - +----------+-----+ + +--------+-----+ + | gender | s | + |--------+-----| + | M | 101 | + +--------+-----+ HAVING without GROUP BY ----------------------- @@ -443,11 +443,11 @@ Additionally, a ``HAVING`` clause can work without ``GROUP BY`` clause. This is ... FROM accounts ... HAVING sum(age) > 100; fetched rows / total rows = 1/1 - +------------------------+ - | 'Total of age > 100' | - |------------------------| - | Total of age > 100 | - +------------------------+ + +----------------------+ + | 'Total of age > 100' | + |----------------------| + | Total of age > 100 | + +----------------------+ FILTER Clause @@ -465,12 +465,12 @@ The group by aggregation with ``FILTER`` clause can set different conditions for os> SELECT avg(age) FILTER(WHERE balance > 10000) AS filtered, gender FROM accounts GROUP BY gender fetched rows / total rows = 2/2 - +------------+----------+ - | filtered | gender | - |------------+----------| - | 28.0 | F | - | 32.0 | M | - +------------+----------+ + +----------+--------+ + | filtered | gender | + |----------+--------| + | 28.0 | F | + | 32.0 | M | + +----------+--------+ FILTER without GROUP BY ----------------------- @@ -482,11 +482,11 @@ The ``FILTER`` clause can be used in aggregation functions without GROUP BY as w ... count(*) FILTER(WHERE age > 34) AS filtered ... FROM accounts fetched rows / total rows = 1/1 - +--------------+------------+ - | unfiltered | filtered | - |--------------+------------| - | 4 | 1 | - +--------------+------------+ + +------------+----------+ + | unfiltered | filtered | + |------------+----------| + | 4 | 1 | + +------------+----------+ Distinct count aggregate with FILTER ------------------------------------ @@ -495,9 +495,9 @@ The ``FILTER`` clause is also used in distinct count to do the filtering before os> SELECT COUNT(DISTINCT firstname) FILTER(WHERE age > 30) AS distinct_count FROM accounts fetched rows / total rows = 1/1 - +------------------+ - | distinct_count | - |------------------| - | 3 | - +------------------+ + +----------------+ + | distinct_count | + |----------------| + | 3 | + +----------------+ diff --git a/docs/user/dql/basics.rst b/docs/user/dql/basics.rst index a03ac4db70..a59f193086 100644 --- a/docs/user/dql/basics.rst +++ b/docs/user/dql/basics.rst @@ -191,14 +191,14 @@ This produces results like this for example:: os> SELECT firstname, lastname, _index, _sort FROM accounts; fetched rows / total rows = 4/4 - +-------------+------------+----------+---------+ - | firstname | lastname | _index | _sort | - |-------------+------------+----------+---------| - | Amber | Duke | accounts | -2 | - | Hattie | Bond | accounts | -2 | - | Nanette | Bates | accounts | -2 | - | Dale | Adams | accounts | -2 | - +-------------+------------+----------+---------+ + +-----------+----------+----------+-------+ + | firstname | lastname | _index | _sort | + |-----------+----------+----------+-------| + | Amber | Duke | accounts | -2 | + | Hattie | Bond | accounts | -2 | + | Nanette | Bates | accounts | -2 | + | Dale | Adams | accounts | -2 | + +-----------+----------+----------+-------+ Example 3: Using Field Alias ---------------------------- @@ -303,13 +303,13 @@ In fact your can use any expression in a ``DISTINCT`` clause as follows:: os> SELECT DISTINCT SUBSTRING(lastname, 1, 1) FROM accounts; fetched rows / total rows = 3/3 - +-----------------------------+ - | SUBSTRING(lastname, 1, 1) | - |-----------------------------| - | A | - | B | - | D | - +-----------------------------+ + +---------------------------+ + | SUBSTRING(lastname, 1, 1) | + |---------------------------| + | A | + | B | + | D | + +---------------------------+ FROM ==== @@ -988,14 +988,14 @@ Note that the example above is essentially sorting on a predicate expression. In os> SELECT employer FROM accounts ORDER BY employer ASC NULLS LAST; fetched rows / total rows = 4/4 - +------------+ - | employer | - |------------| - | Netagy | - | Pyrami | - | Quility | - | null | - +------------+ + +----------+ + | employer | + |----------| + | Netagy | + | Pyrami | + | Quility | + | null | + +----------+ The sorting rule can be summarized as follows: @@ -1010,14 +1010,14 @@ Here is another example for sort in descending order without ``NULLS`` clause:: os> SELECT employer FROM accounts ORDER BY employer DESC; fetched rows / total rows = 4/4 - +------------+ - | employer | - |------------| - | Quility | - | Pyrami | - | Netagy | - | null | - +------------+ + +----------+ + | employer | + |----------| + | Quility | + | Pyrami | + | Netagy | + | null | + +----------+ Example 3: Ordering by Aggregate Functions @@ -1027,23 +1027,23 @@ Aggregate functions are allowed to be used in ``ORDER BY`` clause. You can refer os> SELECT gender, MAX(age) FROM accounts GROUP BY gender ORDER BY MAX(age) DESC; fetched rows / total rows = 2/2 - +----------+------------+ - | gender | MAX(age) | - |----------+------------| - | M | 36 | - | F | 28 | - +----------+------------+ + +--------+----------+ + | gender | MAX(age) | + |--------+----------| + | M | 36 | + | F | 28 | + +--------+----------+ Even if it's not present in ``SELECT`` clause, it can be also used as follows:: os> SELECT gender, MIN(age) FROM accounts GROUP BY gender ORDER BY MAX(age) DESC; fetched rows / total rows = 2/2 - +----------+------------+ - | gender | MIN(age) | - |----------+------------| - | M | 32 | - | F | 28 | - +----------+------------+ + +--------+----------+ + | gender | MIN(age) | + |--------+----------| + | M | 32 | + | F | 28 | + +--------+----------+ LIMIT ===== @@ -1147,12 +1147,12 @@ Offset position can be given following the OFFSET keyword as well, here is an ex >od SELECT age FROM accounts ORDER BY age LIMIT 2 OFFSET 1 fetched rows / total rows = 2/2 - +-------+ - | age | - |-------| - | 32 | - | 33 | - +-------+ + +-----+ + | age | + |-----| + | 32 | + | 33 | + +-----+ Limitation diff --git a/docs/user/dql/complex.rst b/docs/user/dql/complex.rst index 17009d712b..906ea21904 100644 --- a/docs/user/dql/complex.rst +++ b/docs/user/dql/complex.rst @@ -247,14 +247,14 @@ Here is another example with aggregation function and GROUP BY in subquery:: ... SELECT AVG(balance) AS avg_balance FROM accounts GROUP BY gender, age ... ) AS a; fetched rows / total rows = 4/4 - +---------------+ - | avg_balance | - |---------------| - | 32838.0 | - | 39225.0 | - | 4180.0 | - | 5686.0 | - +---------------+ + +-------------+ + | avg_balance | + |-------------| + | 32838.0 | + | 39225.0 | + | 4180.0 | + | 5686.0 | + +-------------+ Query with multiple layers of subquery is supported as well, here follows a example:: @@ -265,12 +265,12 @@ Query with multiple layers of subquery is supported as well, here follows a exam ... ) AS accounts WHERE age < 35 ... ) AS accounts fetched rows / total rows = 2/2 - +--------+ - | name | - |--------| - | Duke | - | Adams | - +--------+ + +-------+ + | name | + |-------| + | Duke | + | Adams | + +-------+ JOINs diff --git a/docs/user/dql/expressions.rst b/docs/user/dql/expressions.rst index 123bba046a..18a5bdce8f 100644 --- a/docs/user/dql/expressions.rst +++ b/docs/user/dql/expressions.rst @@ -34,29 +34,29 @@ Here is an example for different type of literals:: os> SELECT 123, 'hello', false, -4.567, DATE '2020-07-07', TIME '01:01:01', TIMESTAMP '2020-07-07 01:01:01'; fetched rows / total rows = 1/1 - +-------+-----------+---------+----------+---------------------+-------------------+-----------------------------------+ - | 123 | 'hello' | false | -4.567 | DATE '2020-07-07' | TIME '01:01:01' | TIMESTAMP '2020-07-07 01:01:01' | - |-------+-----------+---------+----------+---------------------+-------------------+-----------------------------------| - | 123 | hello | False | -4.567 | 2020-07-07 | 01:01:01 | 2020-07-07 01:01:01 | - +-------+-----------+---------+----------+---------------------+-------------------+-----------------------------------+ + +-----+---------+-------+--------+-------------------+-----------------+---------------------------------+ + | 123 | 'hello' | false | -4.567 | DATE '2020-07-07' | TIME '01:01:01' | TIMESTAMP '2020-07-07 01:01:01' | + |-----+---------+-------+--------+-------------------+-----------------+---------------------------------| + | 123 | hello | False | -4.567 | 2020-07-07 | 01:01:01 | 2020-07-07 01:01:01 | + +-----+---------+-------+--------+-------------------+-----------------+---------------------------------+ os> SELECT "Hello", 'Hello', "It""s", 'It''s', "It's", '"Its"', 'It\'s', 'It\\\'s', "\I\t\s" fetched rows / total rows = 1/1 - +-----------+-----------+-----------+-----------+----------+-----------+-----------+-------------+------------+ - | "Hello" | 'Hello' | "It""s" | 'It''s' | "It's" | '"Its"' | 'It\'s' | 'It\\\'s' | "\I\t\s" | - |-----------+-----------+-----------+-----------+----------+-----------+-----------+-------------+------------| - | Hello | Hello | It"s | It's | It's | "Its" | It's | It\'s | \I\t\s | - +-----------+-----------+-----------+-----------+----------+-----------+-----------+-------------+------------+ + +---------+---------+---------+---------+--------+---------+---------+-----------+----------+ + | "Hello" | 'Hello' | "It""s" | 'It''s' | "It's" | '"Its"' | 'It\'s' | 'It\\\'s' | "\I\t\s" | + |---------+---------+---------+---------+--------+---------+---------+-----------+----------| + | Hello | Hello | It"s | It's | It's | "Its" | It's | It\'s | \I\t\s | + +---------+---------+---------+---------+--------+---------+---------+-----------+----------+ os> SELECT {DATE '2020-07-07'}, {D '2020-07-07'}, {TIME '01:01:01'}, {T '01:01:01'}, {TIMESTAMP '2020-07-07 01:01:01'}, {TS '2020-07-07 01:01:01'} fetched rows / total rows = 1/1 - +-----------------------+--------------------+---------------------+------------------+-------------------------------------+------------------------------+ - | {DATE '2020-07-07'} | {D '2020-07-07'} | {TIME '01:01:01'} | {T '01:01:01'} | {TIMESTAMP '2020-07-07 01:01:01'} | {TS '2020-07-07 01:01:01'} | - |-----------------------+--------------------+---------------------+------------------+-------------------------------------+------------------------------| - | 2020-07-07 | 2020-07-07 | 01:01:01 | 01:01:01 | 2020-07-07 01:01:01 | 2020-07-07 01:01:01 | - +-----------------------+--------------------+---------------------+------------------+-------------------------------------+------------------------------+ + +---------------------+------------------+-------------------+----------------+-----------------------------------+----------------------------+ + | {DATE '2020-07-07'} | {D '2020-07-07'} | {TIME '01:01:01'} | {T '01:01:01'} | {TIMESTAMP '2020-07-07 01:01:01'} | {TS '2020-07-07 01:01:01'} | + |---------------------+------------------+-------------------+----------------+-----------------------------------+----------------------------| + | 2020-07-07 | 2020-07-07 | 01:01:01 | 01:01:01 | 2020-07-07 01:01:01 | 2020-07-07 01:01:01 | + +---------------------+------------------+-------------------+----------------+-----------------------------------+----------------------------+ Limitations ----------- @@ -102,11 +102,11 @@ Here is an example for different type of arithmetic expressions:: os> SELECT 1 + 2, (9 - 1) % 3, 2 * 4 / 3; fetched rows / total rows = 1/1 - +---------+---------------+-------------+ - | 1 + 2 | (9 - 1) % 3 | 2 * 4 / 3 | - |---------+---------------+-------------| - | 3 | 2 | 2 | - +---------+---------------+-------------+ + +-------+-------------+-----------+ + | 1 + 2 | (9 - 1) % 3 | 2 * 4 / 3 | + |-------+-------------+-----------| + | 3 | 2 | 2 | + +-------+-------------+-----------+ Comparison Operators ================================== @@ -162,38 +162,38 @@ Here is an example for different type of comparison operators:: os> SELECT 2 > 1, 2 >= 1, 2 < 1, 2 != 1, 2 <= 1, 2 = 1; fetched rows / total rows = 1/1 - +---------+----------+---------+----------+----------+---------+ - | 2 > 1 | 2 >= 1 | 2 < 1 | 2 != 1 | 2 <= 1 | 2 = 1 | - |---------+----------+---------+----------+----------+---------| - | True | True | False | True | False | False | - +---------+----------+---------+----------+----------+---------+ + +-------+--------+-------+--------+--------+-------+ + | 2 > 1 | 2 >= 1 | 2 < 1 | 2 != 1 | 2 <= 1 | 2 = 1 | + |-------+--------+-------+--------+--------+-------| + | True | True | False | True | False | False | + +-------+--------+-------+--------+--------+-------+ It is possible to compare datetimes. When comparing different datetime types, for example `DATE` and `TIME`, both converted to `TIMESTAMP`. The following rule is applied on coversion: a `TIME` applied to today's date; `DATE` is interpreted at midnight. See example below:: os> SELECT current_time() > current_date() AS `now.time > today`, typeof(current_time()) AS `now.time.type`, typeof(current_date()) AS `now.date.type`; fetched rows / total rows = 1/1 - +--------------------+-----------------+-----------------+ - | now.time > today | now.time.type | now.date.type | - |--------------------+-----------------+-----------------| - | True | TIME | DATE | - +--------------------+-----------------+-----------------+ + +------------------+---------------+---------------+ + | now.time > today | now.time.type | now.date.type | + |------------------+---------------+---------------| + | True | TIME | DATE | + +------------------+---------------+---------------+ os> SELECT current_time() = now() AS `now.time = now`, typeof(current_time()) AS `now.time.type`, typeof(now()) AS `now.type`; fetched rows / total rows = 1/1 - +------------------+-----------------+------------+ - | now.time = now | now.time.type | now.type | - |------------------+-----------------+------------| - | True | TIME | TIMESTAMP | - +------------------+-----------------+------------+ + +----------------+---------------+-----------+ + | now.time = now | now.time.type | now.type | + |----------------+---------------+-----------| + | True | TIME | TIMESTAMP | + +----------------+---------------+-----------+ os> SELECT subtime(now(), current_time()) = current_date() AS `midnight = now.date`, typeof(subtime(now(), current_time())) AS `midnight.type`, typeof(current_date()) AS `now.date.type`; fetched rows / total rows = 1/1 - +-----------------------+-----------------+-----------------+ - | midnight = now.date | midnight.type | now.date.type | - |-----------------------+-----------------+-----------------| - | True | TIMESTAMP | DATE | - +-----------------------+-----------------+-----------------+ + +---------------------+---------------+---------------+ + | midnight = now.date | midnight.type | now.date.type | + |---------------------+---------------+---------------| + | True | TIMESTAMP | DATE | + +---------------------+---------------+---------------+ LIKE @@ -203,11 +203,11 @@ expr LIKE pattern. The expr is string value, pattern is supports literal text, a os> SELECT 'axyzb' LIKE 'a%b', 'acb' LIKE 'A_B', 'axyzb' NOT LIKE 'a%b', 'acb' NOT LIKE 'a_b'; fetched rows / total rows = 1/1 - +----------------------+--------------------+--------------------------+------------------------+ - | 'axyzb' LIKE 'a%b' | 'acb' LIKE 'A_B' | 'axyzb' NOT LIKE 'a%b' | 'acb' NOT LIKE 'a_b' | - |----------------------+--------------------+--------------------------+------------------------| - | True | True | False | False | - +----------------------+--------------------+--------------------------+------------------------+ + +--------------------+------------------+------------------------+----------------------+ + | 'axyzb' LIKE 'a%b' | 'acb' LIKE 'A_B' | 'axyzb' NOT LIKE 'a%b' | 'acb' NOT LIKE 'a_b' | + |--------------------+------------------+------------------------+----------------------| + | True | True | False | False | + +--------------------+------------------+------------------------+----------------------+ NULL value test --------------- @@ -216,11 +216,11 @@ Here is an example for null value test:: os> SELECT 0 IS NULL, 0 IS NOT NULL, NULL IS NULL, NULL IS NOT NULL; fetched rows / total rows = 1/1 - +-------------+-----------------+----------------+--------------------+ - | 0 IS NULL | 0 IS NOT NULL | NULL IS NULL | NULL IS NOT NULL | - |-------------+-----------------+----------------+--------------------| - | False | True | True | False | - +-------------+-----------------+----------------+--------------------+ + +-----------+---------------+--------------+------------------+ + | 0 IS NULL | 0 IS NOT NULL | NULL IS NULL | NULL IS NOT NULL | + |-----------+---------------+--------------+------------------| + | False | True | True | False | + +-----------+---------------+--------------+------------------+ REGEXP value test @@ -230,11 +230,11 @@ expr REGEXP pattern. The expr is string value, pattern is supports regular expre os> SELECT 'Hello!' REGEXP '.*', 'a' REGEXP 'b'; fetched rows / total rows = 1/1 - +------------------------+------------------+ - | 'Hello!' REGEXP '.*' | 'a' REGEXP 'b' | - |------------------------+------------------| - | 1 | 0 | - +------------------------+------------------+ + +----------------------+----------------+ + | 'Hello!' REGEXP '.*' | 'a' REGEXP 'b' | + |----------------------+----------------| + | 1 | 0 | + +----------------------+----------------+ IN value list test ------------------ @@ -243,11 +243,11 @@ Here is an example for IN value test:: os> SELECT 1 in (1, 2), 3 not in (1, 2); fetched rows / total rows = 1/1 - +---------------+-------------------+ - | 1 in (1, 2) | 3 not in (1, 2) | - |---------------+-------------------| - | True | True | - +---------------+-------------------+ + +-------------+-----------------+ + | 1 in (1, 2) | 3 not in (1, 2) | + |-------------+-----------------| + | True | True | + +-------------+-----------------+ BETWEEN range test ------------------ @@ -259,11 +259,11 @@ Here is an example for range test by BETWEEN expression:: ... 4 BETWEEN 1 AND 3, ... 4 NOT BETWEEN 1 AND 3; fetched rows / total rows = 1/1 - +---------------------+---------------------+-------------------------+ - | 1 BETWEEN 1 AND 3 | 4 BETWEEN 1 AND 3 | 4 NOT BETWEEN 1 AND 3 | - |---------------------+---------------------+-------------------------| - | True | False | True | - +---------------------+---------------------+-------------------------+ + +-------------------+-------------------+-----------------------+ + | 1 BETWEEN 1 AND 3 | 4 BETWEEN 1 AND 3 | 4 NOT BETWEEN 1 AND 3 | + |-------------------+-------------------+-----------------------| + | True | False | True | + +-------------------+-------------------+-----------------------+ Function Call @@ -293,11 +293,11 @@ Here is an example for different type of arithmetic expressions:: os> SELECT abs(-1.234), abs(-1 * abs(-5)); fetched rows / total rows = 1/1 - +---------------+---------------------+ - | abs(-1.234) | abs(-1 * abs(-5)) | - |---------------+---------------------| - | 1.234 | 5 | - +---------------+---------------------+ + +-------------+-------------------+ + | abs(-1.234) | abs(-1 * abs(-5)) | + |-------------+-------------------| + | 1.234 | 5 | + +-------------+-------------------+ Date function examples ---------------------- @@ -306,11 +306,11 @@ Here is an example for different type of arithmetic expressions:: os> SELECT dayofmonth(DATE '2020-07-07'); fetched rows / total rows = 1/1 - +---------------------------------+ - | dayofmonth(DATE '2020-07-07') | - |---------------------------------| - | 7 | - +---------------------------------+ + +-------------------------------+ + | dayofmonth(DATE '2020-07-07') | + |-------------------------------| + | 7 | + +-------------------------------+ Limitations ----------- diff --git a/docs/user/dql/functions.rst b/docs/user/dql/functions.rst index b445fffa63..a347614ba4 100644 --- a/docs/user/dql/functions.rst +++ b/docs/user/dql/functions.rst @@ -49,21 +49,21 @@ Cast to string example:: os> SELECT cast(true as string) as cbool, cast(1 as string) as cint, cast(DATE '2012-08-07' as string) as cdate fetched rows / total rows = 1/1 - +---------+--------+------------+ - | cbool | cint | cdate | - |---------+--------+------------| - | true | 1 | 2012-08-07 | - +---------+--------+------------+ + +-------+------+------------+ + | cbool | cint | cdate | + |-------+------+------------| + | true | 1 | 2012-08-07 | + +-------+------+------------+ Cast to number example:: os> SELECT cast(true as int) as cbool, cast('1' as integer) as cstring fetched rows / total rows = 1/1 - +---------+-----------+ - | cbool | cstring | - |---------+-----------| - | 1 | 1 | - +---------+-----------+ + +-------+---------+ + | cbool | cstring | + |-------+---------| + | 1 | 1 | + +-------+---------+ Cast to date example:: @@ -79,11 +79,11 @@ Cast function can be chained:: os> SELECT cast(cast(true as string) as boolean) as cbool fetched rows / total rows = 1/1 - +---------+ - | cbool | - |---------| - | True | - +---------+ + +-------+ + | cbool | + |-------| + | True | + +-------+ Mathematical Functions @@ -103,11 +103,11 @@ Example:: os> SELECT ABS(0), ABS(10), ABS(-10), ABS(12.34567), ABS(-12.34567) fetched rows / total rows = 1/1 - +----------+-----------+------------+-----------------+------------------+ - | ABS(0) | ABS(10) | ABS(-10) | ABS(12.34567) | ABS(-12.34567) | - |----------+-----------+------------+-----------------+------------------| - | 0 | 10 | 10 | 12.34567 | 12.34567 | - +----------+-----------+------------+-----------------+------------------+ + +--------+---------+----------+---------------+----------------+ + | ABS(0) | ABS(10) | ABS(-10) | ABS(12.34567) | ABS(-12.34567) | + |--------+---------+----------+---------------+----------------| + | 0 | 10 | 10 | 12.34567 | 12.34567 | + +--------+---------+----------+---------------+----------------+ ACOS @@ -151,11 +151,11 @@ Example:: os> SELECT ADD(2, 1), ADD(2.5, 3); fetched rows / total rows = 1/1 - +-------------+---------------+ - | ADD(2, 1) | ADD(2.5, 3) | - |-------------+---------------| - | 3 | 5.5 | - +-------------+---------------+ + +-----------+-------------+ + | ADD(2, 1) | ADD(2.5, 3) | + |-----------+-------------| + | 3 | 5.5 | + +-----------+-------------+ ASIN ---- @@ -173,11 +173,11 @@ Example:: os> SELECT ASIN(0) fetched rows / total rows = 1/1 - +-----------+ - | ASIN(0) | - |-----------| - | 0.0 | - +-----------+ + +---------+ + | ASIN(0) | + |---------| + | 0.0 | + +---------+ ATAN @@ -244,11 +244,11 @@ Example:: os> SELECT CBRT(8), CBRT(9.261), CBRT(-27); fetched rows / total rows = 1/1 - +-----------+---------------+-------------+ - | CBRT(8) | CBRT(9.261) | CBRT(-27) | - |-----------+---------------+-------------| - | 2.0 | 2.1 | -3.0 | - +-----------+---------------+-------------+ + +---------+-------------+-----------+ + | CBRT(8) | CBRT(9.261) | CBRT(-27) | + |---------+-------------+-----------| + | 2.0 | 2.1 | -3.0 | + +---------+-------------+-----------+ CEIL @@ -281,29 +281,29 @@ Example:: os> SELECT CEILING(0), CEILING(50.00005), CEILING(-50.00005); fetched rows / total rows = 1/1 - +--------------+---------------------+----------------------+ - | CEILING(0) | CEILING(50.00005) | CEILING(-50.00005) | - |--------------+---------------------+----------------------| - | 0 | 51 | -50 | - +--------------+---------------------+----------------------+ + +------------+-------------------+--------------------+ + | CEILING(0) | CEILING(50.00005) | CEILING(-50.00005) | + |------------+-------------------+--------------------| + | 0 | 51 | -50 | + +------------+-------------------+--------------------+ os> SELECT CEILING(3147483647.12345), CEILING(113147483647.12345), CEILING(3147483647.00001); fetched rows / total rows = 1/1 - +-----------------------------+-------------------------------+-----------------------------+ - | CEILING(3147483647.12345) | CEILING(113147483647.12345) | CEILING(3147483647.00001) | - |-----------------------------+-------------------------------+-----------------------------| - | 3147483648 | 113147483648 | 3147483648 | - +-----------------------------+-------------------------------+-----------------------------+ + +---------------------------+-----------------------------+---------------------------+ + | CEILING(3147483647.12345) | CEILING(113147483647.12345) | CEILING(3147483647.00001) | + |---------------------------+-----------------------------+---------------------------| + | 3147483648 | 113147483648 | 3147483648 | + +---------------------------+-----------------------------+---------------------------+ Example:: os> SELECT CEIL(0), CEIL(12.34567), CEIL(-12.34567) fetched rows / total rows = 1/1 - +-----------+------------------+-------------------+ - | CEIL(0) | CEIL(12.34567) | CEIL(-12.34567) | - |-----------+------------------+-------------------| - | 0 | 13 | -12 | - +-----------+------------------+-------------------+ + +---------+----------------+-----------------+ + | CEIL(0) | CEIL(12.34567) | CEIL(-12.34567) | + |---------+----------------+-----------------| + | 0 | 13 | -12 | + +---------+----------------+-----------------+ CONV @@ -322,11 +322,11 @@ Example:: os> SELECT CONV('12', 10, 16), CONV('2C', 16, 10), CONV(12, 10, 2), CONV(1111, 2, 10) fetched rows / total rows = 1/1 - +----------------------+----------------------+-------------------+---------------------+ - | CONV('12', 10, 16) | CONV('2C', 16, 10) | CONV(12, 10, 2) | CONV(1111, 2, 10) | - |----------------------+----------------------+-------------------+---------------------| - | c | 44 | 1100 | 15 | - +----------------------+----------------------+-------------------+---------------------+ + +--------------------+--------------------+-----------------+-------------------+ + | CONV('12', 10, 16) | CONV('2C', 16, 10) | CONV(12, 10, 2) | CONV(1111, 2, 10) | + |--------------------+--------------------+-----------------+-------------------| + | c | 44 | 1100 | 15 | + +--------------------+--------------------+-----------------+-------------------+ COS @@ -345,11 +345,11 @@ Example:: os> SELECT COS(0) fetched rows / total rows = 1/1 - +----------+ - | COS(0) | - |----------| - | 1.0 | - +----------+ + +--------+ + | COS(0) | + |--------| + | 1.0 | + +--------+ COSH @@ -414,11 +414,11 @@ Example:: os> SELECT CRC32('MySQL') fetched rows / total rows = 1/1 - +------------------+ - | CRC32('MySQL') | - |------------------| - | 3259397556 | - +------------------+ + +----------------+ + | CRC32('MySQL') | + |----------------| + | 3259397556 | + +----------------+ DEGREES @@ -462,11 +462,11 @@ Example:: os> SELECT DIVIDE(10, 2), DIVIDE(7.5, 3); fetched rows / total rows = 1/1 - +-----------------+------------------+ - | DIVIDE(10, 2) | DIVIDE(7.5, 3) | - |-----------------+------------------| - | 5 | 2.5 | - +-----------------+------------------+ + +---------------+----------------+ + | DIVIDE(10, 2) | DIVIDE(7.5, 3) | + |---------------+----------------| + | 5 | 2.5 | + +---------------+----------------+ E @@ -533,11 +533,11 @@ Example:: os> SELECT EXPM1(-1), EXPM1(0), EXPM1(1), EXPM1(1.5) fetched rows / total rows = 1/1 - +---------------------+------------+-------------------+-------------------+ - | EXPM1(-1) | EXPM1(0) | EXPM1(1) | EXPM1(1.5) | - |---------------------+------------+-------------------+-------------------| - | -0.6321205588285577 | 0.0 | 1.718281828459045 | 3.481689070338065 | - +---------------------+------------+-------------------+-------------------+ + +---------------------+----------+-------------------+-------------------+ + | EXPM1(-1) | EXPM1(0) | EXPM1(1) | EXPM1(1.5) | + |---------------------+----------+-------------------+-------------------| + | -0.6321205588285577 | 0.0 | 1.718281828459045 | 3.481689070338065 | + +---------------------+----------+-------------------+-------------------+ FLOOR @@ -558,27 +558,27 @@ Example:: os> SELECT FLOOR(0), FLOOR(50.00005), FLOOR(-50.00005); fetched rows / total rows = 1/1 - +------------+-------------------+--------------------+ - | FLOOR(0) | FLOOR(50.00005) | FLOOR(-50.00005) | - |------------+-------------------+--------------------| - | 0 | 50 | -51 | - +------------+-------------------+--------------------+ + +----------+-----------------+------------------+ + | FLOOR(0) | FLOOR(50.00005) | FLOOR(-50.00005) | + |----------+-----------------+------------------| + | 0 | 50 | -51 | + +----------+-----------------+------------------+ os> SELECT FLOOR(3147483647.12345), FLOOR(113147483647.12345), FLOOR(3147483647.00001); fetched rows / total rows = 1/1 - +---------------------------+-----------------------------+---------------------------+ - | FLOOR(3147483647.12345) | FLOOR(113147483647.12345) | FLOOR(3147483647.00001) | - |---------------------------+-----------------------------+---------------------------| - | 3147483647 | 113147483647 | 3147483647 | - +---------------------------+-----------------------------+---------------------------+ + +-------------------------+---------------------------+-------------------------+ + | FLOOR(3147483647.12345) | FLOOR(113147483647.12345) | FLOOR(3147483647.00001) | + |-------------------------+---------------------------+-------------------------| + | 3147483647 | 113147483647 | 3147483647 | + +-------------------------+---------------------------+-------------------------+ os> SELECT FLOOR(282474973688888.022), FLOOR(9223372036854775807.022), FLOOR(9223372036854775807.0000001); fetched rows / total rows = 1/1 - +------------------------------+----------------------------------+--------------------------------------+ - | FLOOR(282474973688888.022) | FLOOR(9223372036854775807.022) | FLOOR(9223372036854775807.0000001) | - |------------------------------+----------------------------------+--------------------------------------| - | 282474973688888 | 9223372036854775807 | 9223372036854775807 | - +------------------------------+----------------------------------+--------------------------------------+ + +----------------------------+--------------------------------+------------------------------------+ + | FLOOR(282474973688888.022) | FLOOR(9223372036854775807.022) | FLOOR(9223372036854775807.0000001) | + |----------------------------+--------------------------------+------------------------------------| + | 282474973688888 | 9223372036854775807 | 9223372036854775807 | + +----------------------------+--------------------------------+------------------------------------+ LN @@ -597,11 +597,11 @@ Example:: os> select LN(1), LN(e()), LN(10), LN(12.34567); fetched rows / total rows = 1/1 - +---------+-----------+-------------------+--------------------+ - | LN(1) | LN(e()) | LN(10) | LN(12.34567) | - |---------+-----------+-------------------+--------------------| - | 0.0 | 1.0 | 2.302585092994046 | 2.5133053943094317 | - +---------+-----------+-------------------+--------------------+ + +-------+---------+-------------------+--------------------+ + | LN(1) | LN(e()) | LN(10) | LN(12.34567) | + |-------+---------+-------------------+--------------------| + | 0.0 | 1.0 | 2.302585092994046 | 2.5133053943094317 | + +-------+---------+-------------------+--------------------+ LOG @@ -623,11 +623,11 @@ Example:: os> select LOG(1), LOG(e()), LOG(2, 65536), LOG(10, 10000); fetched rows / total rows = 1/1 - +----------+------------+-----------------+------------------+ - | LOG(1) | LOG(e()) | LOG(2, 65536) | LOG(10, 10000) | - |----------+------------+-----------------+------------------| - | 0.0 | 1.0 | 16.0 | 4.0 | - +----------+------------+-----------------+------------------+ + +--------+----------+---------------+----------------+ + | LOG(1) | LOG(e()) | LOG(2, 65536) | LOG(10, 10000) | + |--------+----------+---------------+----------------| + | 0.0 | 1.0 | 16.0 | 4.0 | + +--------+----------+---------------+----------------+ LOG2 @@ -646,11 +646,11 @@ Example:: os> select LOG2(1), LOG2(8), LOG2(65536), LOG2(8.8245); fetched rows / total rows = 1/1 - +-----------+-----------+---------------+--------------------+ - | LOG2(1) | LOG2(8) | LOG2(65536) | LOG2(8.8245) | - |-----------+-----------+---------------+--------------------| - | 0.0 | 3.0 | 16.0 | 3.1415145369723745 | - +-----------+-----------+---------------+--------------------+ + +---------+---------+-------------+--------------------+ + | LOG2(1) | LOG2(8) | LOG2(65536) | LOG2(8.8245) | + |---------+---------+-------------+--------------------| + | 0.0 | 3.0 | 16.0 | 3.1415145369723745 | + +---------+---------+-------------+--------------------+ LOG10 @@ -669,11 +669,11 @@ Example:: os> select LOG10(1), LOG10(8), LOG10(1000), LOG10(8.8245); fetched rows / total rows = 1/1 - +------------+--------------------+---------------+--------------------+ - | LOG10(1) | LOG10(8) | LOG10(1000) | LOG10(8.8245) | - |------------+--------------------+---------------+--------------------| - | 0.0 | 0.9030899869919435 | 3.0 | 0.9456901074431278 | - +------------+--------------------+---------------+--------------------+ + +----------+--------------------+-------------+--------------------+ + | LOG10(1) | LOG10(8) | LOG10(1000) | LOG10(8.8245) | + |----------+--------------------+-------------+--------------------| + | 0.0 | 0.9030899869919435 | 3.0 | 0.9456901074431278 | + +----------+--------------------+-------------+--------------------+ MOD @@ -694,11 +694,11 @@ Example:: os> SELECT MOD(3, 2), MOD(3.1, 2) fetched rows / total rows = 1/1 - +-------------+---------------+ - | MOD(3, 2) | MOD(3.1, 2) | - |-------------+---------------| - | 1 | 1.1 | - +-------------+---------------+ + +-----------+-------------+ + | MOD(3, 2) | MOD(3.1, 2) | + |-----------+-------------| + | 1 | 1.1 | + +-----------+-------------+ MODULUS ------- @@ -718,11 +718,11 @@ Example:: os> SELECT MODULUS(3, 2), MODULUS(3.1, 2) fetched rows / total rows = 1/1 - +-----------------+-------------------+ - | MODULUS(3, 2) | MODULUS(3.1, 2) | - |-----------------+-------------------| - | 1 | 1.1 | - +-----------------+-------------------+ + +---------------+-----------------+ + | MODULUS(3, 2) | MODULUS(3.1, 2) | + |---------------+-----------------| + | 1 | 1.1 | + +---------------+-----------------+ MULTIPLY @@ -743,11 +743,11 @@ Example:: os> SELECT MULTIPLY(1, 2), MULTIPLY(-2, 1), MULTIPLY(1.5, 2); fetched rows / total rows = 1/1 - +------------------+-------------------+--------------------+ - | MULTIPLY(1, 2) | MULTIPLY(-2, 1) | MULTIPLY(1.5, 2) | - |------------------+-------------------+--------------------| - | 2 | -2 | 3.0 | - +------------------+-------------------+--------------------+ + +----------------+-----------------+------------------+ + | MULTIPLY(1, 2) | MULTIPLY(-2, 1) | MULTIPLY(1.5, 2) | + |----------------+-----------------+------------------| + | 2 | -2 | 3.0 | + +----------------+-----------------+------------------+ PI @@ -789,11 +789,11 @@ Example:: os> SELECT POW(3, 2), POW(-3, 2), POW(3, -2) fetched rows / total rows = 1/1 - +-------------+--------------+--------------------+ - | POW(3, 2) | POW(-3, 2) | POW(3, -2) | - |-------------+--------------+--------------------| - | 9.0 | 9.0 | 0.1111111111111111 | - +-------------+--------------+--------------------+ + +-----------+------------+--------------------+ + | POW(3, 2) | POW(-3, 2) | POW(3, -2) | + |-----------+------------+--------------------| + | 9.0 | 9.0 | 0.1111111111111111 | + +-----------+------------+--------------------+ POWER @@ -814,11 +814,11 @@ Example:: os> SELECT POWER(3, 2), POWER(-3, 2), POWER(3, -2) fetched rows / total rows = 1/1 - +---------------+----------------+--------------------+ - | POWER(3, 2) | POWER(-3, 2) | POWER(3, -2) | - |---------------+----------------+--------------------| - | 9.0 | 9.0 | 0.1111111111111111 | - +---------------+----------------+--------------------+ + +-------------+--------------+--------------------+ + | POWER(3, 2) | POWER(-3, 2) | POWER(3, -2) | + |-------------+--------------+--------------------| + | 9.0 | 9.0 | 0.1111111111111111 | + +-------------+--------------+--------------------+ RADIANS @@ -883,11 +883,11 @@ Example:: os> SELECT RINT(1.7); fetched rows / total rows = 1/1 - +-------------+ - | RINT(1.7) | - |-------------| - | 2.0 | - +-------------+ + +-----------+ + | RINT(1.7) | + |-----------| + | 2.0 | + +-----------+ ROUND @@ -910,11 +910,11 @@ Example:: os> SELECT ROUND(12.34), ROUND(12.34, 1), ROUND(12.34, -1), ROUND(12, 1) fetched rows / total rows = 1/1 - +----------------+-------------------+--------------------+----------------+ - | ROUND(12.34) | ROUND(12.34, 1) | ROUND(12.34, -1) | ROUND(12, 1) | - |----------------+-------------------+--------------------+----------------| - | 12.0 | 12.3 | 10.0 | 12 | - +----------------+-------------------+--------------------+----------------+ + +--------------+-----------------+------------------+--------------+ + | ROUND(12.34) | ROUND(12.34, 1) | ROUND(12.34, -1) | ROUND(12, 1) | + |--------------+-----------------+------------------+--------------| + | 12.0 | 12.3 | 10.0 | 12 | + +--------------+-----------------+------------------+--------------+ SIGN @@ -933,11 +933,11 @@ Example:: os> SELECT SIGN(1), SIGN(0), SIGN(-1.1) fetched rows / total rows = 1/1 - +-----------+-----------+--------------+ - | SIGN(1) | SIGN(0) | SIGN(-1.1) | - |-----------+-----------+--------------| - | 1 | 0 | -1 | - +-----------+-----------+--------------+ + +---------+---------+------------+ + | SIGN(1) | SIGN(0) | SIGN(-1.1) | + |---------+---------+------------| + | 1 | 0 | -1 | + +---------+---------+------------+ SIGNUM @@ -958,11 +958,11 @@ Example:: os> SELECT SIGNUM(1), SIGNUM(0), SIGNUM(-1.1) fetched rows / total rows = 1/1 - +-------------+-------------+----------------+ - | SIGNUM(1) | SIGNUM(0) | SIGNUM(-1.1) | - |-------------+-------------+----------------| - | 1 | 0 | -1 | - +-------------+-------------+----------------+ + +-----------+-----------+--------------+ + | SIGNUM(1) | SIGNUM(0) | SIGNUM(-1.1) | + |-----------+-----------+--------------| + | 1 | 0 | -1 | + +-----------+-----------+--------------+ SIN @@ -981,11 +981,11 @@ Example:: os> select sin(0), sin(1), sin(pi()), abs(sin(pi())) < 0.0001; fetched rows / total rows = 1/1 - +----------+--------------------+------------------------+---------------------------+ - | sin(0) | sin(1) | sin(pi()) | abs(sin(pi())) < 0.0001 | - |----------+--------------------+------------------------+---------------------------| - | 0.0 | 0.8414709848078965 | 1.2246467991473532e-16 | True | - +----------+--------------------+------------------------+---------------------------+ + +--------+--------------------+------------------------+-------------------------+ + | sin(0) | sin(1) | sin(pi()) | abs(sin(pi())) < 0.0001 | + |--------+--------------------+------------------------+-------------------------| + | 0.0 | 0.8414709848078965 | 1.2246467991473532e-16 | True | + +--------+--------------------+------------------------+-------------------------+ SINH @@ -1030,11 +1030,11 @@ Example:: os> SELECT SQRT(4), SQRT(4.41) fetched rows / total rows = 1/1 - +-----------+--------------+ - | SQRT(4) | SQRT(4.41) | - |-----------+--------------| - | 2.0 | 2.1 | - +-----------+--------------+ + +---------+------------+ + | SQRT(4) | SQRT(4.41) | + |---------+------------| + | 2.0 | 2.1 | + +---------+------------+ STRCMP @@ -1053,11 +1053,11 @@ Example:: os> SELECT STRCMP('hello', 'world'), STRCMP('hello', 'hello') fetched rows / total rows = 1/1 - +----------------------------+----------------------------+ - | STRCMP('hello', 'world') | STRCMP('hello', 'hello') | - |----------------------------+----------------------------| - | -1 | 0 | - +----------------------------+----------------------------+ + +--------------------------+--------------------------+ + | STRCMP('hello', 'world') | STRCMP('hello', 'hello') | + |--------------------------+--------------------------| + | -1 | 0 | + +--------------------------+--------------------------+ SUBTRACT @@ -1078,11 +1078,11 @@ Example:: os> SELECT SUBTRACT(2, 1), SUBTRACT(2.5, 3); fetched rows / total rows = 1/1 - +------------------+--------------------+ - | SUBTRACT(2, 1) | SUBTRACT(2.5, 3) | - |------------------+--------------------| - | 1 | -0.5 | - +------------------+--------------------+ + +----------------+------------------+ + | SUBTRACT(2, 1) | SUBTRACT(2.5, 3) | + |----------------+------------------| + | 1 | -0.5 | + +----------------+------------------+ TAN @@ -1101,11 +1101,11 @@ Example:: os> SELECT TAN(0) fetched rows / total rows = 1/1 - +----------+ - | TAN(0) | - |----------| - | 0.0 | - +----------+ + +--------+ + | TAN(0) | + |--------| + | 0.0 | + +--------+ TRUNCATE @@ -1126,11 +1126,11 @@ FLOAT/DOUBLE -> DOUBLE Example:: fetched rows / total rows = 1/1 - +----------------------+-----------------------+-------------------+ - | TRUNCATE(56.78, 1) | TRUNCATE(56.78, -1) | TRUNCATE(56, 1) | - |----------------------+-----------------------+-------------------| - | 56.7 | 50 | 56 | - +----------------------+-----------------------+-------------------+ + +--------------------+---------------------+-----------------+ + | TRUNCATE(56.78, 1) | TRUNCATE(56.78, -1) | TRUNCATE(56, 1) | + |--------------------+---------------------+-----------------| + | 56.7 | 50 | 56 | + +--------------------+---------------------+-----------------+ Date and Time Functions @@ -1163,11 +1163,11 @@ Example:: os> SELECT ADDDATE(DATE('2020-08-26'), INTERVAL 1 HOUR) AS `'2020-08-26' + 1h`, ADDDATE(DATE('2020-08-26'), 1) AS `'2020-08-26' + 1`, ADDDATE(TIMESTAMP('2020-08-26 01:01:01'), 1) AS `ts '2020-08-26 01:01:01' + 1` fetched rows / total rows = 1/1 - +---------------------+--------------------+--------------------------------+ - | '2020-08-26' + 1h | '2020-08-26' + 1 | ts '2020-08-26 01:01:01' + 1 | - |---------------------+--------------------+--------------------------------| - | 2020-08-26 01:00:00 | 2020-08-27 | 2020-08-27 01:01:01 | - +---------------------+--------------------+--------------------------------+ + +---------------------+------------------+------------------------------+ + | '2020-08-26' + 1h | '2020-08-26' + 1 | ts '2020-08-26 01:01:01' + 1 | + |---------------------+------------------+------------------------------| + | 2020-08-26 01:00:00 | 2020-08-27 | 2020-08-27 01:01:01 | + +---------------------+------------------+------------------------------+ ADDTIME @@ -1200,35 +1200,35 @@ Example:: os> SELECT ADDTIME(TIME('23:59:59'), DATE('2004-01-01')) AS `'23:59:59' + 0` fetched rows / total rows = 1/1 - +------------------+ - | '23:59:59' + 0 | - |------------------| - | 23:59:59 | - +------------------+ + +----------------+ + | '23:59:59' + 0 | + |----------------| + | 23:59:59 | + +----------------+ os> SELECT ADDTIME(DATE('2004-01-01'), TIME('23:59:59')) AS `'2004-01-01' + '23:59:59'` fetched rows / total rows = 1/1 - +-----------------------------+ - | '2004-01-01' + '23:59:59' | - |-----------------------------| - | 2004-01-01 23:59:59 | - +-----------------------------+ - - os> SELECT ADDTIME(TIME('10:20:30'), TIME('00:05:42')) AS `'10:20:30' + '00:05:42'` - fetched rows / total rows = 1/1 +---------------------------+ - | '10:20:30' + '00:05:42' | + | '2004-01-01' + '23:59:59' | |---------------------------| - | 10:26:12 | + | 2004-01-01 23:59:59 | +---------------------------+ + os> SELECT ADDTIME(TIME('10:20:30'), TIME('00:05:42')) AS `'10:20:30' + '00:05:42'` + fetched rows / total rows = 1/1 + +-------------------------+ + | '10:20:30' + '00:05:42' | + |-------------------------| + | 10:26:12 | + +-------------------------+ + os> SELECT ADDTIME(TIMESTAMP('2007-02-28 10:20:30'), TIMESTAMP('2002-03-04 20:40:50')) AS `'2007-02-28 10:20:30' + '20:40:50'` fetched rows / total rows = 1/1 - +--------------------------------------+ - | '2007-02-28 10:20:30' + '20:40:50' | - |--------------------------------------| - | 2007-03-01 07:01:20 | - +--------------------------------------+ + +------------------------------------+ + | '2007-02-28 10:20:30' + '20:40:50' | + |------------------------------------| + | 2007-03-01 07:01:20 | + +------------------------------------+ CONVERT_TZ @@ -1247,86 +1247,86 @@ Example:: os> SELECT CONVERT_TZ('2008-12-25 05:30:00', '+00:00', 'America/Los_Angeles') fetched rows / total rows = 1/1 - +----------------------------------------------------------------------+ - | CONVERT_TZ('2008-12-25 05:30:00', '+00:00', 'America/Los_Angeles') | - |----------------------------------------------------------------------| - | 2008-12-24 21:30:00 | - +----------------------------------------------------------------------+ + +--------------------------------------------------------------------+ + | CONVERT_TZ('2008-12-25 05:30:00', '+00:00', 'America/Los_Angeles') | + |--------------------------------------------------------------------| + | 2008-12-24 21:30:00 | + +--------------------------------------------------------------------+ os> SELECT CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "-10:00") fetched rows / total rows = 1/1 - +---------------------------------------------------------+ - | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "-10:00") | - |---------------------------------------------------------| - | 2010-10-09 23:10:10 | - +---------------------------------------------------------+ + +-------------------------------------------------------+ + | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "-10:00") | + |-------------------------------------------------------| + | 2010-10-09 23:10:10 | + +-------------------------------------------------------+ When the datedate, or either of the two time zone fields are invalid format, then the result is null. In this example any timestamp that is not will result in null. Example:: os> SELECT CONVERT_TZ("test", "+01:00", "-10:00") fetched rows / total rows = 1/1 - +------------------------------------------+ - | CONVERT_TZ("test", "+01:00", "-10:00") | - |------------------------------------------| - | null | - +------------------------------------------+ + +----------------------------------------+ + | CONVERT_TZ("test", "+01:00", "-10:00") | + |----------------------------------------| + | null | + +----------------------------------------+ When the timestamp, or either of the two time zone fields are invalid format, then the result is null. In this example any timezone that is not <+HH:mm> or <-HH:mm> will result in null. Example:: os> SELECT CONVERT_TZ("2010-10-10 10:10:10", "test", "-10:00") fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | CONVERT_TZ("2010-10-10 10:10:10", "test", "-10:00") | - |-------------------------------------------------------| - | null | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | CONVERT_TZ("2010-10-10 10:10:10", "test", "-10:00") | + |-----------------------------------------------------| + | null | + +-----------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. Timezones outside of the range will result in null. Example:: os> SELECT CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "+14:00") fetched rows / total rows = 1/1 - +---------------------------------------------------------+ - | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "+14:00") | - |---------------------------------------------------------| - | 2010-10-10 23:10:10 | - +---------------------------------------------------------+ + +-------------------------------------------------------+ + | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "+14:00") | + |-------------------------------------------------------| + | 2010-10-10 23:10:10 | + +-------------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. Timezones outside of the range will result in null. Example:: os> SELECT CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "+14:01") fetched rows / total rows = 1/1 - +---------------------------------------------------------+ - | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "+14:01") | - |---------------------------------------------------------| - | null | - +---------------------------------------------------------+ + +-------------------------------------------------------+ + | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "+14:01") | + |-------------------------------------------------------| + | null | + +-------------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. Timezones outside of the range will result in null. Example:: os> SELECT CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "-13:59") fetched rows / total rows = 1/1 - +---------------------------------------------------------+ - | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "-13:59") | - |---------------------------------------------------------| - | 2010-10-09 19:11:10 | - +---------------------------------------------------------+ + +-------------------------------------------------------+ + | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "-13:59") | + |-------------------------------------------------------| + | 2010-10-09 19:11:10 | + +-------------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. Timezones outside of the range will result in null. Example:: os> SELECT CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "-14:00") fetched rows / total rows = 1/1 - +---------------------------------------------------------+ - | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "-14:00") | - |---------------------------------------------------------| - | null | - +---------------------------------------------------------+ + +-------------------------------------------------------+ + | CONVERT_TZ("2010-10-10 10:10:10", "+01:00", "-14:00") | + |-------------------------------------------------------| + | null | + +-------------------------------------------------------+ CURDATE @@ -1346,11 +1346,11 @@ Example:: > SELECT CURDATE(); fetched rows / total rows = 1/1 - +-------------+ - | CURDATE() | - |-------------| - | 2022-08-02 | - +-------------+ + +------------+ + | CURDATE() | + |------------| + | 2022-08-02 | + +------------+ CURRENT_DATE @@ -1365,11 +1365,11 @@ Example:: > SELECT CURRENT_DATE(); fetched rows / total rows = 1/1 - +------------------+ - | CURRENT_DATE() | - |------------------+ - | 2022-08-02 | - +------------------+ + +----------------+ + | CURRENT_DATE() | + |----------------+ + | 2022-08-02 | + +----------------+ CURRENT_TIME @@ -1384,11 +1384,11 @@ Example:: > SELECT CURRENT_TIME(); fetched rows / total rows = 1/1 - +-----------------+ - | CURRENT_TIME() | - |-----------------+ - | 15:39:05 | - +-----------------+ + +----------------+ + | CURRENT_TIME() | + |----------------+ + | 15:39:05 | + +----------------+ CURRENT_TIMESTAMP @@ -1403,11 +1403,11 @@ Example:: > SELECT CURRENT_TIMESTAMP(); fetched rows / total rows = 1/1 - +-----------------------+ - | CURRENT_TIMESTAMP() | - |-----------------------+ - | 2022-08-02 15:54:19 | - +-----------------------+ + +---------------------+ + | CURRENT_TIMESTAMP() | + |---------------------+ + | 2022-08-02 15:54:19 | + +---------------------+ CURTIME @@ -1427,11 +1427,11 @@ Example:: > SELECT CURTIME() as value_1, CURTIME() as value_2; fetched rows / total rows = 1/1 - +-----------+-----------+ - | value_1 | value_2 | - |-----------+-----------| - | 15:39:05 | 15:39:05 | - +-----------+-----------+ + +----------+----------+ + | value_1 | value_2 | + |----------+----------| + | 15:39:05 | 15:39:05 | + +----------+----------+ DATE @@ -1450,11 +1450,11 @@ Example:: os> SELECT DATE('2020-08-26'), DATE(TIMESTAMP('2020-08-26 13:49:00')), DATE('2020-08-26 13:49:00'), DATE('2020-08-26 13:49') fetched rows / total rows = 1/1 - +----------------------+------------------------------------------+-------------------------------+----------------------------+ - | DATE('2020-08-26') | DATE(TIMESTAMP('2020-08-26 13:49:00')) | DATE('2020-08-26 13:49:00') | DATE('2020-08-26 13:49') | - |----------------------+------------------------------------------+-------------------------------+----------------------------| - | 2020-08-26 | 2020-08-26 | 2020-08-26 | 2020-08-26 | - +----------------------+------------------------------------------+-------------------------------+----------------------------+ + +--------------------+----------------------------------------+-----------------------------+--------------------------+ + | DATE('2020-08-26') | DATE(TIMESTAMP('2020-08-26 13:49:00')) | DATE('2020-08-26 13:49:00') | DATE('2020-08-26 13:49') | + |--------------------+----------------------------------------+-----------------------------+--------------------------| + | 2020-08-26 | 2020-08-26 | 2020-08-26 | 2020-08-26 | + +--------------------+----------------------------------------+-----------------------------+--------------------------+ DATETIME @@ -1477,44 +1477,44 @@ Example:: os> SELECT DATETIME('2008-12-25 05:30:00+00:00', 'America/Los_Angeles') fetched rows / total rows = 1/1 - +----------------------------------------------------------------+ - | DATETIME('2008-12-25 05:30:00+00:00', 'America/Los_Angeles') | - |----------------------------------------------------------------| - | 2008-12-24 21:30:00 | - +----------------------------------------------------------------+ + +--------------------------------------------------------------+ + | DATETIME('2008-12-25 05:30:00+00:00', 'America/Los_Angeles') | + |--------------------------------------------------------------| + | 2008-12-24 21:30:00 | + +--------------------------------------------------------------+ This example converts from -10:00 timezone to +10:00 timezone. Example:: os> SELECT DATETIME('2004-02-28 23:00:00-10:00', '+10:00') fetched rows / total rows = 1/1 - +---------------------------------------------------+ - | DATETIME('2004-02-28 23:00:00-10:00', '+10:00') | - |---------------------------------------------------| - | 2004-02-29 19:00:00 | - +---------------------------------------------------+ + +-------------------------------------------------+ + | DATETIME('2004-02-28 23:00:00-10:00', '+10:00') | + |-------------------------------------------------| + | 2004-02-29 19:00:00 | + +-------------------------------------------------+ This example uses the timezone -14:00, which is outside of the range -13:59 and +14:00. This results in a null value. Example:: os> SELECT DATETIME('2008-01-01 02:00:00', '-14:00') fetched rows / total rows = 1/1 - +---------------------------------------------+ - | DATETIME('2008-01-01 02:00:00', '-14:00') | - |---------------------------------------------| - | null | - +---------------------------------------------+ + +-------------------------------------------+ + | DATETIME('2008-01-01 02:00:00', '-14:00') | + |-------------------------------------------| + | null | + +-------------------------------------------+ February 30th is not a day, so it returns null. Example:: os> SELECT DATETIME('2008-02-30 02:00:00', '-00:00') fetched rows / total rows = 1/1 - +---------------------------------------------+ - | DATETIME('2008-02-30 02:00:00', '-00:00') | - |---------------------------------------------| - | null | - +---------------------------------------------+ + +-------------------------------------------+ + | DATETIME('2008-02-30 02:00:00', '-00:00') | + |-------------------------------------------| + | null | + +-------------------------------------------+ DATETIME(datetime) examples @@ -1523,33 +1523,33 @@ Example:: os> SELECT DATETIME('2008-02-10 02:00:00') fetched rows / total rows = 1/1 - +-----------------------------------+ - | DATETIME('2008-02-10 02:00:00') | - |-----------------------------------| - | 2008-02-10 02:00:00 | - +-----------------------------------+ + +---------------------------------+ + | DATETIME('2008-02-10 02:00:00') | + |---------------------------------| + | 2008-02-10 02:00:00 | + +---------------------------------+ February 30th is not a day, so it returns null. Example:: os> SELECT DATETIME('2008-02-30 02:00:00') fetched rows / total rows = 1/1 - +-----------------------------------+ - | DATETIME('2008-02-30 02:00:00') | - |-----------------------------------| - | null | - +-----------------------------------+ + +---------------------------------+ + | DATETIME('2008-02-30 02:00:00') | + |---------------------------------| + | null | + +---------------------------------+ DATETIME with a datetime and no seperate timezone to convert to returns the datetime object without a timezone. Example:: os> SELECT DATETIME('2008-02-10 02:00:00+04:00') fetched rows / total rows = 1/1 - +-----------------------------------------+ - | DATETIME('2008-02-10 02:00:00+04:00') | - |-----------------------------------------| - | 2008-02-10 02:00:00 | - +-----------------------------------------+ + +---------------------------------------+ + | DATETIME('2008-02-10 02:00:00+04:00') | + |---------------------------------------| + | 2008-02-10 02:00:00 | + +---------------------------------------+ DATE_ADD @@ -1572,11 +1572,11 @@ Example:: os> SELECT DATE_ADD(DATE('2020-08-26'), INTERVAL 1 HOUR) AS `'2020-08-26' + 1h`, DATE_ADD(TIMESTAMP('2020-08-26 01:01:01'), INTERVAL 1 DAY) as `ts '2020-08-26 01:01:01' + 1d` fetched rows / total rows = 1/1 - +---------------------+---------------------------------+ - | '2020-08-26' + 1h | ts '2020-08-26 01:01:01' + 1d | - |---------------------+---------------------------------| - | 2020-08-26 01:00:00 | 2020-08-27 01:01:01 | - +---------------------+---------------------------------+ + +---------------------+-------------------------------+ + | '2020-08-26' + 1h | ts '2020-08-26 01:01:01' + 1d | + |---------------------+-------------------------------| + | 2020-08-26 01:00:00 | 2020-08-27 01:01:01 | + +---------------------+-------------------------------+ DATE_FORMAT @@ -1671,11 +1671,11 @@ Example:: os> SELECT DATE_FORMAT('1998-01-31 13:14:15.012345', '%T.%f'), DATE_FORMAT(TIMESTAMP('1998-01-31 13:14:15.012345'), '%Y-%b-%D %r') fetched rows / total rows = 1/1 - +------------------------------------------------------+-----------------------------------------------------------------------+ - | DATE_FORMAT('1998-01-31 13:14:15.012345', '%T.%f') | DATE_FORMAT(TIMESTAMP('1998-01-31 13:14:15.012345'), '%Y-%b-%D %r') | - |------------------------------------------------------+-----------------------------------------------------------------------| - | 13:14:15.012345 | 1998-Jan-31st 01:14:15 PM | - +------------------------------------------------------+-----------------------------------------------------------------------+ + +----------------------------------------------------+---------------------------------------------------------------------+ + | DATE_FORMAT('1998-01-31 13:14:15.012345', '%T.%f') | DATE_FORMAT(TIMESTAMP('1998-01-31 13:14:15.012345'), '%Y-%b-%D %r') | + |----------------------------------------------------+---------------------------------------------------------------------| + | 13:14:15.012345 | 1998-Jan-31st 01:14:15 PM | + +----------------------------------------------------+---------------------------------------------------------------------+ DATE_SUB @@ -1698,11 +1698,11 @@ Example:: os> SELECT DATE_SUB(DATE('2008-01-02'), INTERVAL 31 DAY) AS `'2008-01-02' - 31d`, DATE_SUB(TIMESTAMP('2020-08-26 01:01:01'), INTERVAL 1 HOUR) AS `ts '2020-08-26 01:01:01' + 1h` fetched rows / total rows = 1/1 - +----------------------+---------------------------------+ - | '2008-01-02' - 31d | ts '2020-08-26 01:01:01' + 1h | - |----------------------+---------------------------------| - | 2007-12-02 00:00:00 | 2020-08-26 00:01:01 | - +----------------------+---------------------------------+ + +---------------------+-------------------------------+ + | '2008-01-02' - 31d | ts '2020-08-26 01:01:01' + 1h | + |---------------------+-------------------------------| + | 2007-12-02 00:00:00 | 2020-08-26 00:01:01 | + +---------------------+-------------------------------+ DATEDIFF @@ -1718,11 +1718,11 @@ Example:: os> SELECT DATEDIFF(TIMESTAMP('2000-01-02 00:00:00'), TIMESTAMP('2000-01-01 23:59:59')) AS `'2000-01-02' - '2000-01-01'`, DATEDIFF(DATE('2001-02-01'), TIMESTAMP('2004-01-01 00:00:00')) AS `'2001-02-01' - '2004-01-01'`, DATEDIFF(TIME('23:59:59'), TIME('00:00:00')) AS `today - today` fetched rows / total rows = 1/1 - +-------------------------------+-------------------------------+-----------------+ - | '2000-01-02' - '2000-01-01' | '2001-02-01' - '2004-01-01' | today - today | - |-------------------------------+-------------------------------+-----------------| - | 1 | -1064 | 0 | - +-------------------------------+-------------------------------+-----------------+ + +-----------------------------+-----------------------------+---------------+ + | '2000-01-02' - '2000-01-01' | '2001-02-01' - '2004-01-01' | today - today | + |-----------------------------+-----------------------------+---------------| + | 1 | -1064 | 0 | + +-----------------------------+-----------------------------+---------------+ DAY @@ -1743,11 +1743,11 @@ Example:: os> SELECT DAY(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +---------------------------+ - | DAY(DATE('2020-08-26')) | - |---------------------------| - | 26 | - +---------------------------+ + +-------------------------+ + | DAY(DATE('2020-08-26')) | + |-------------------------| + | 26 | + +-------------------------+ DAYNAME @@ -1766,11 +1766,11 @@ Example:: os> SELECT DAYNAME(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +-------------------------------+ - | DAYNAME(DATE('2020-08-26')) | - |-------------------------------| - | Wednesday | - +-------------------------------+ + +-----------------------------+ + | DAYNAME(DATE('2020-08-26')) | + |-----------------------------| + | Wednesday | + +-----------------------------+ DAYOFMONTH @@ -1791,11 +1791,11 @@ Example:: os> SELECT DAYOFMONTH(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +----------------------------------+ - | DAYOFMONTH(DATE('2020-08-26')) | - |----------------------------------| - | 26 | - +----------------------------------+ + +--------------------------------+ + | DAYOFMONTH(DATE('2020-08-26')) | + |--------------------------------| + | 26 | + +--------------------------------+ DAY_OF_MONTH @@ -1816,11 +1816,11 @@ Example:: os> SELECT DAY_OF_MONTH('2020-08-26') fetched rows / total rows = 1/1 - +------------------------------+ - | DAY_OF_MONTH('2020-08-26') | - |------------------------------| - | 26 | - +------------------------------+ + +----------------------------+ + | DAY_OF_MONTH('2020-08-26') | + |----------------------------| + | 26 | + +----------------------------+ DAYOFWEEK @@ -1841,11 +1841,11 @@ Example:: os> SELECT DAYOFWEEK('2020-08-26'), DAY_OF_WEEK('2020-08-26') fetched rows / total rows = 1/1 - +---------------------------+-----------------------------+ - | DAYOFWEEK('2020-08-26') | DAY_OF_WEEK('2020-08-26') | - |---------------------------+-----------------------------| - | 4 | 4 | - +---------------------------+-----------------------------+ + +-------------------------+---------------------------+ + | DAYOFWEEK('2020-08-26') | DAY_OF_WEEK('2020-08-26') | + |-------------------------+---------------------------| + | 4 | 4 | + +-------------------------+---------------------------+ DAYOFYEAR @@ -1866,19 +1866,19 @@ Example:: os> SELECT DAYOFYEAR(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +---------------------------------+ - | DAYOFYEAR(DATE('2020-08-26')) | - |---------------------------------| - | 239 | - +---------------------------------+ + +-------------------------------+ + | DAYOFYEAR(DATE('2020-08-26')) | + |-------------------------------| + | 239 | + +-------------------------------+ os> SELECT DAYOFYEAR(TIMESTAMP('2020-08-26 00:00:00')) fetched rows / total rows = 1/1 - +-----------------------------------------------+ - | DAYOFYEAR(TIMESTAMP('2020-08-26 00:00:00')) | - |-----------------------------------------------| - | 239 | - +-----------------------------------------------+ + +---------------------------------------------+ + | DAYOFYEAR(TIMESTAMP('2020-08-26 00:00:00')) | + |---------------------------------------------| + | 239 | + +---------------------------------------------+ DAY_OF_YEAR @@ -1898,19 +1898,19 @@ Example:: os> SELECT DAY_OF_YEAR(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +-----------------------------------+ - | DAY_OF_YEAR(DATE('2020-08-26')) | - |-----------------------------------| - | 239 | - +-----------------------------------+ + +---------------------------------+ + | DAY_OF_YEAR(DATE('2020-08-26')) | + |---------------------------------| + | 239 | + +---------------------------------+ os> SELECT DAY_OF_YEAR(TIMESTAMP('2020-08-26 00:00:00')) fetched rows / total rows = 1/1 - +-------------------------------------------------+ - | DAY_OF_YEAR(TIMESTAMP('2020-08-26 00:00:00')) | - |-------------------------------------------------| - | 239 | - +-------------------------------------------------+ + +-----------------------------------------------+ + | DAY_OF_YEAR(TIMESTAMP('2020-08-26 00:00:00')) | + |-----------------------------------------------| + | 239 | + +-----------------------------------------------+ EXTRACT @@ -1978,11 +1978,11 @@ Example:: os> SELECT extract(YEAR_MONTH FROM "2023-02-07 10:11:12"); fetched rows / total rows = 1/1 - +--------------------------------------------------+ - | extract(YEAR_MONTH FROM "2023-02-07 10:11:12") | - |--------------------------------------------------| - | 202302 | - +--------------------------------------------------+ + +------------------------------------------------+ + | extract(YEAR_MONTH FROM "2023-02-07 10:11:12") | + |------------------------------------------------| + | 202302 | + +------------------------------------------------+ FROM_DAYS @@ -2001,11 +2001,11 @@ Example:: os> SELECT FROM_DAYS(733687) fetched rows / total rows = 1/1 - +---------------------+ - | FROM_DAYS(733687) | - |---------------------| - | 2008-10-07 | - +---------------------+ + +-------------------+ + | FROM_DAYS(733687) | + |-------------------| + | 2008-10-07 | + +-------------------+ FROM_UNIXTIME @@ -2030,19 +2030,19 @@ Examples:: os> select FROM_UNIXTIME(1220249547) fetched rows / total rows = 1/1 - +-----------------------------+ - | FROM_UNIXTIME(1220249547) | - |-----------------------------| - | 2008-09-01 06:12:27 | - +-----------------------------+ + +---------------------------+ + | FROM_UNIXTIME(1220249547) | + |---------------------------| + | 2008-09-01 06:12:27 | + +---------------------------+ os> select FROM_UNIXTIME(1220249547, '%T') fetched rows / total rows = 1/1 - +-----------------------------------+ - | FROM_UNIXTIME(1220249547, '%T') | - |-----------------------------------| - | 06:12:27 | - +-----------------------------------+ + +---------------------------------+ + | FROM_UNIXTIME(1220249547, '%T') | + |---------------------------------| + | 06:12:27 | + +---------------------------------+ GET_FORMAT @@ -2061,11 +2061,11 @@ Examples:: os> select GET_FORMAT(DATE, 'USA'); fetched rows / total rows = 1/1 - +---------------------------+ - | GET_FORMAT(DATE, 'USA') | - |---------------------------| - | %m.%d.%Y | - +---------------------------+ + +-------------------------+ + | GET_FORMAT(DATE, 'USA') | + |-------------------------| + | %m.%d.%Y | + +-------------------------+ HOUR @@ -2085,11 +2085,11 @@ Example:: os> SELECT HOUR('01:02:03'), HOUR_OF_DAY('01:02:03') fetched rows / total rows = 1/1 - +--------------------+---------------------------+ - | HOUR('01:02:03') | HOUR_OF_DAY('01:02:03') | - |--------------------+---------------------------| - | 1 | 1 | - +--------------------+---------------------------+ + +------------------+-------------------------+ + | HOUR('01:02:03') | HOUR_OF_DAY('01:02:03') | + |------------------+-------------------------| + | 1 | 1 | + +------------------+-------------------------+ LAST_DAY @@ -2105,11 +2105,11 @@ Example:: os> SELECT last_day('2023-02-06'); fetched rows / total rows = 1/1 - +--------------------------+ - | last_day('2023-02-06') | - |--------------------------| - | 2023-02-28 | - +--------------------------+ + +------------------------+ + | last_day('2023-02-06') | + |------------------------| + | 2023-02-28 | + +------------------------+ LOCALTIMESTAMP @@ -2177,11 +2177,11 @@ Example:: os> select MAKEDATE(1945, 5.9), MAKEDATE(1984, 1984) fetched rows / total rows = 1/1 - +-----------------------+------------------------+ - | MAKEDATE(1945, 5.9) | MAKEDATE(1984, 1984) | - |-----------------------+------------------------| - | 1945-01-06 | 1989-06-06 | - +-----------------------+------------------------+ + +---------------------+----------------------+ + | MAKEDATE(1945, 5.9) | MAKEDATE(1984, 1984) | + |---------------------+----------------------| + | 1945-01-06 | 1989-06-06 | + +---------------------+----------------------+ MAKETIME @@ -2209,11 +2209,11 @@ Example:: os> select MAKETIME(20, 30, 40), MAKETIME(20.2, 49.5, 42.100502) fetched rows / total rows = 1/1 - +------------------------+-----------------------------------+ - | MAKETIME(20, 30, 40) | MAKETIME(20.2, 49.5, 42.100502) | - |------------------------+-----------------------------------| - | 20:30:40 | 20:50:42.100502 | - +------------------------+-----------------------------------+ + +----------------------+---------------------------------+ + | MAKETIME(20, 30, 40) | MAKETIME(20.2, 49.5, 42.100502) | + |----------------------+---------------------------------| + | 20:30:40 | 20:50:42.100502 | + +----------------------+---------------------------------+ MICROSECOND @@ -2232,11 +2232,11 @@ Example:: os> SELECT MICROSECOND((TIME '01:02:03.123456')) fetched rows / total rows = 1/1 - +-----------------------------------------+ - | MICROSECOND((TIME '01:02:03.123456')) | - |-----------------------------------------| - | 123456 | - +-----------------------------------------+ + +---------------------------------------+ + | MICROSECOND((TIME '01:02:03.123456')) | + |---------------------------------------| + | 123456 | + +---------------------------------------+ MINUTE @@ -2256,11 +2256,11 @@ Example:: os> SELECT MINUTE(time('01:02:03')), MINUTE_OF_HOUR(time('01:02:03')) fetched rows / total rows = 1/1 - +----------------------------+------------------------------------+ - | MINUTE(time('01:02:03')) | MINUTE_OF_HOUR(time('01:02:03')) | - |----------------------------+------------------------------------| - | 2 | 2 | - +----------------------------+------------------------------------+ + +--------------------------+----------------------------------+ + | MINUTE(time('01:02:03')) | MINUTE_OF_HOUR(time('01:02:03')) | + |--------------------------+----------------------------------| + | 2 | 2 | + +--------------------------+----------------------------------+ MINUTE_OF_DAY @@ -2279,11 +2279,11 @@ Example:: os> SELECT MINUTE_OF_DAY((TIME '01:02:03')) fetched rows / total rows = 1/1 - +------------------------------------+ - | MINUTE_OF_DAY((TIME '01:02:03')) | - |------------------------------------| - | 62 | - +------------------------------------+ + +----------------------------------+ + | MINUTE_OF_DAY((TIME '01:02:03')) | + |----------------------------------| + | 62 | + +----------------------------------+ MONTH @@ -2304,20 +2304,20 @@ Example:: os> SELECT MONTH(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +-----------------------------+ - | MONTH(DATE('2020-08-26')) | - |-----------------------------| - | 8 | - +-----------------------------+ + +---------------------------+ + | MONTH(DATE('2020-08-26')) | + |---------------------------| + | 8 | + +---------------------------+ os> SELECT MONTH_OF_YEAR(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +-------------------------------------+ - | MONTH_OF_YEAR(DATE('2020-08-26')) | - |-------------------------------------| - | 8 | - +-------------------------------------+ + +-----------------------------------+ + | MONTH_OF_YEAR(DATE('2020-08-26')) | + |-----------------------------------| + | 8 | + +-----------------------------------+ MONTHNAME @@ -2336,11 +2336,11 @@ Example:: os> SELECT MONTHNAME(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +---------------------------------+ - | MONTHNAME(DATE('2020-08-26')) | - |---------------------------------| - | August | - +---------------------------------+ + +-------------------------------+ + | MONTHNAME(DATE('2020-08-26')) | + |-------------------------------| + | August | + +-------------------------------+ NOW @@ -2383,11 +2383,11 @@ Example:: os> SELECT PERIOD_ADD(200801, 2), PERIOD_ADD(200801, -12) fetched rows / total rows = 1/1 - +-------------------------+---------------------------+ - | PERIOD_ADD(200801, 2) | PERIOD_ADD(200801, -12) | - |-------------------------+---------------------------| - | 200803 | 200701 | - +-------------------------+---------------------------+ + +-----------------------+-------------------------+ + | PERIOD_ADD(200801, 2) | PERIOD_ADD(200801, -12) | + |-----------------------+-------------------------| + | 200803 | 200701 | + +-----------------------+-------------------------+ PERIOD_DIFF @@ -2406,11 +2406,11 @@ Example:: os> SELECT PERIOD_DIFF(200802, 200703), PERIOD_DIFF(200802, 201003) fetched rows / total rows = 1/1 - +-------------------------------+-------------------------------+ - | PERIOD_DIFF(200802, 200703) | PERIOD_DIFF(200802, 201003) | - |-------------------------------+-------------------------------| - | 11 | -25 | - +-------------------------------+-------------------------------+ + +-----------------------------+-----------------------------+ + | PERIOD_DIFF(200802, 200703) | PERIOD_DIFF(200802, 201003) | + |-----------------------------+-----------------------------| + | 11 | -25 | + +-----------------------------+-----------------------------+ QUARTER @@ -2429,11 +2429,11 @@ Example:: os> SELECT QUARTER(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +-------------------------------+ - | QUARTER(DATE('2020-08-26')) | - |-------------------------------| - | 3 | - +-------------------------------+ + +-----------------------------+ + | QUARTER(DATE('2020-08-26')) | + |-----------------------------| + | 3 | + +-----------------------------+ SEC_TO_TIME @@ -2455,27 +2455,27 @@ Example:: os> SELECT SEC_TO_TIME(3601) fetched rows / total rows = 1/1 - +---------------------+ - | SEC_TO_TIME(3601) | - |---------------------| - | 01:00:01 | - +---------------------+ + +-------------------+ + | SEC_TO_TIME(3601) | + |-------------------| + | 01:00:01 | + +-------------------+ os> SELECT sec_to_time(1234.123); fetched rows / total rows = 1/1 - +-------------------------+ - | sec_to_time(1234.123) | - |-------------------------| - | 00:20:34.123 | - +-------------------------+ + +-----------------------+ + | sec_to_time(1234.123) | + |-----------------------| + | 00:20:34.123 | + +-----------------------+ os> SELECT sec_to_time(NULL); fetched rows / total rows = 1/1 - +---------------------+ - | sec_to_time(NULL) | - |---------------------| - | null | - +---------------------+ + +-------------------+ + | sec_to_time(NULL) | + |-------------------| + | null | + +-------------------+ SECOND @@ -2495,19 +2495,19 @@ Example:: os> SELECT SECOND((TIME '01:02:03')) fetched rows / total rows = 1/1 - +-----------------------------+ - | SECOND((TIME '01:02:03')) | - |-----------------------------| - | 3 | - +-----------------------------+ + +---------------------------+ + | SECOND((TIME '01:02:03')) | + |---------------------------| + | 3 | + +---------------------------+ os> SELECT SECOND_OF_MINUTE(time('01:02:03')) fetched rows / total rows = 1/1 - +--------------------------------------+ - | SECOND_OF_MINUTE(time('01:02:03')) | - |--------------------------------------| - | 3 | - +--------------------------------------+ + +------------------------------------+ + | SECOND_OF_MINUTE(time('01:02:03')) | + |------------------------------------| + | 3 | + +------------------------------------+ STR_TO_DATE @@ -2529,11 +2529,11 @@ Example:: OS> SELECT str_to_date("01,5,2013", "%d,%m,%Y") fetched rows / total rows = 1/1 - +----------------------------------------+ - | str_to_date("01,5,2013", "%d,%m,%Y") | - |----------------------------------------| - | 2013-05-01 00:00:00 | - +----------------------------------------+ + +--------------------------------------+ + | str_to_date("01,5,2013", "%d,%m,%Y") | + |--------------------------------------| + | 2013-05-01 00:00:00 | + +--------------------------------------+ SUBDATE @@ -2563,11 +2563,11 @@ Example:: os> SELECT SUBDATE(DATE('2008-01-02'), INTERVAL 31 DAY) AS `'2008-01-02' - 31d`, SUBDATE(DATE('2020-08-26'), 1) AS `'2020-08-26' - 1`, SUBDATE(TIMESTAMP('2020-08-26 01:01:01'), 1) AS `ts '2020-08-26 01:01:01' - 1` fetched rows / total rows = 1/1 - +----------------------+--------------------+--------------------------------+ - | '2008-01-02' - 31d | '2020-08-26' - 1 | ts '2020-08-26 01:01:01' - 1 | - |----------------------+--------------------+--------------------------------| - | 2007-12-02 00:00:00 | 2020-08-25 | 2020-08-25 01:01:01 | - +----------------------+--------------------+--------------------------------+ + +---------------------+------------------+------------------------------+ + | '2008-01-02' - 31d | '2020-08-26' - 1 | ts '2020-08-26 01:01:01' - 1 | + |---------------------+------------------+------------------------------| + | 2007-12-02 00:00:00 | 2020-08-25 | 2020-08-25 01:01:01 | + +---------------------+------------------+------------------------------+ SUBTIME @@ -2600,35 +2600,35 @@ Example:: os> SELECT SUBTIME(TIME('23:59:59'), DATE('2004-01-01')) AS `'23:59:59' - 0` fetched rows / total rows = 1/1 - +------------------+ - | '23:59:59' - 0 | - |------------------| - | 23:59:59 | - +------------------+ + +----------------+ + | '23:59:59' - 0 | + |----------------| + | 23:59:59 | + +----------------+ os> SELECT SUBTIME(DATE('2004-01-01'), TIME('23:59:59')) AS `'2004-01-01' - '23:59:59'` fetched rows / total rows = 1/1 - +-----------------------------+ - | '2004-01-01' - '23:59:59' | - |-----------------------------| - | 2003-12-31 00:00:01 | - +-----------------------------+ - - os> SELECT SUBTIME(TIME('10:20:30'), TIME('00:05:42')) AS `'10:20:30' - '00:05:42'` - fetched rows / total rows = 1/1 +---------------------------+ - | '10:20:30' - '00:05:42' | + | '2004-01-01' - '23:59:59' | |---------------------------| - | 10:14:48 | + | 2003-12-31 00:00:01 | +---------------------------+ + os> SELECT SUBTIME(TIME('10:20:30'), TIME('00:05:42')) AS `'10:20:30' - '00:05:42'` + fetched rows / total rows = 1/1 + +-------------------------+ + | '10:20:30' - '00:05:42' | + |-------------------------| + | 10:14:48 | + +-------------------------+ + os> SELECT SUBTIME(TIMESTAMP('2007-03-01 10:20:30'), TIMESTAMP('2002-03-04 20:40:50')) AS `'2007-03-01 10:20:30' - '20:40:50'` fetched rows / total rows = 1/1 - +--------------------------------------+ - | '2007-03-01 10:20:30' - '20:40:50' | - |--------------------------------------| - | 2007-02-28 13:39:40 | - +--------------------------------------+ + +------------------------------------+ + | '2007-03-01 10:20:30' - '20:40:50' | + |------------------------------------| + | 2007-02-28 13:39:40 | + +------------------------------------+ SYSDATE @@ -2674,11 +2674,11 @@ Example:: os> SELECT TIME('13:49:00'), TIME('13:49'), TIME(TIMESTAMP('2020-08-26 13:49:00')), TIME('2020-08-26 13:49:00') fetched rows / total rows = 1/1 - +--------------------+-----------------+------------------------------------------+-------------------------------+ - | TIME('13:49:00') | TIME('13:49') | TIME(TIMESTAMP('2020-08-26 13:49:00')) | TIME('2020-08-26 13:49:00') | - |--------------------+-----------------+------------------------------------------+-------------------------------| - | 13:49:00 | 13:49:00 | 13:49:00 | 13:49:00 | - +--------------------+-----------------+------------------------------------------+-------------------------------+ + +------------------+---------------+----------------------------------------+-----------------------------+ + | TIME('13:49:00') | TIME('13:49') | TIME(TIMESTAMP('2020-08-26 13:49:00')) | TIME('2020-08-26 13:49:00') | + |------------------+---------------+----------------------------------------+-----------------------------| + | 13:49:00 | 13:49:00 | 13:49:00 | 13:49:00 | + +------------------+---------------+----------------------------------------+-----------------------------+ TIME_FORMAT ----------- @@ -2728,11 +2728,11 @@ Example:: os> SELECT TIME_FORMAT('1998-01-31 13:14:15.012345', '%f %H %h %I %i %p %r %S %s %T') fetched rows / total rows = 1/1 - +------------------------------------------------------------------------------+ - | TIME_FORMAT('1998-01-31 13:14:15.012345', '%f %H %h %I %i %p %r %S %s %T') | - |------------------------------------------------------------------------------| - | 012345 13 01 01 14 PM 01:14:15 PM 15 15 13:14:15 | - +------------------------------------------------------------------------------+ + +----------------------------------------------------------------------------+ + | TIME_FORMAT('1998-01-31 13:14:15.012345', '%f %H %h %I %i %p %r %S %s %T') | + |----------------------------------------------------------------------------| + | 012345 13 01 01 14 PM 01:14:15 PM 15 15 13:14:15 | + +----------------------------------------------------------------------------+ TIME_TO_SEC @@ -2751,11 +2751,11 @@ Example:: os> SELECT TIME_TO_SEC(TIME '22:23:00') fetched rows / total rows = 1/1 - +--------------------------------+ - | TIME_TO_SEC(TIME '22:23:00') | - |--------------------------------| - | 80580 | - +--------------------------------+ + +------------------------------+ + | TIME_TO_SEC(TIME '22:23:00') | + |------------------------------| + | 80580 | + +------------------------------+ TIMEDIFF @@ -2774,11 +2774,11 @@ Example:: os> SELECT TIMEDIFF('23:59:59', '13:00:00') fetched rows / total rows = 1/1 - +------------------------------------+ - | TIMEDIFF('23:59:59', '13:00:00') | - |------------------------------------| - | 10:59:59 | - +------------------------------------+ + +----------------------------------+ + | TIMEDIFF('23:59:59', '13:00:00') | + |----------------------------------| + | 10:59:59 | + +----------------------------------+ TIMESTAMP @@ -2802,11 +2802,11 @@ Example:: os> SELECT TIMESTAMP('2020-08-26 13:49:00'), TIMESTAMP('2020-08-26 13:49:00', TIME('12:15:42')) fetched rows / total rows = 1/1 - +------------------------------------+------------------------------------------------------+ - | TIMESTAMP('2020-08-26 13:49:00') | TIMESTAMP('2020-08-26 13:49:00', TIME('12:15:42')) | - |------------------------------------+------------------------------------------------------| - | 2020-08-26 13:49:00 | 2020-08-27 02:04:42 | - +------------------------------------+------------------------------------------------------+ + +----------------------------------+----------------------------------------------------+ + | TIMESTAMP('2020-08-26 13:49:00') | TIMESTAMP('2020-08-26 13:49:00', TIME('12:15:42')) | + |----------------------------------+----------------------------------------------------| + | 2020-08-26 13:49:00 | 2020-08-27 02:04:42 | + +----------------------------------+----------------------------------------------------+ TIMESTAMPADD @@ -2826,11 +2826,11 @@ Examples:: os> SELECT TIMESTAMPADD(DAY, 17, '2000-01-01 00:00:00'), TIMESTAMPADD(QUARTER, -1, '2000-01-01 00:00:00') fetched rows / total rows = 1/1 - +------------------------------------------------+----------------------------------------------------+ - | TIMESTAMPADD(DAY, 17, '2000-01-01 00:00:00') | TIMESTAMPADD(QUARTER, -1, '2000-01-01 00:00:00') | - |------------------------------------------------+----------------------------------------------------| - | 2000-01-18 00:00:00 | 1999-10-01 00:00:00 | - +------------------------------------------------+----------------------------------------------------+ + +----------------------------------------------+--------------------------------------------------+ + | TIMESTAMPADD(DAY, 17, '2000-01-01 00:00:00') | TIMESTAMPADD(QUARTER, -1, '2000-01-01 00:00:00') | + |----------------------------------------------+--------------------------------------------------| + | 2000-01-18 00:00:00 | 1999-10-01 00:00:00 | + +----------------------------------------------+--------------------------------------------------+ TIMESTAMPDIFF @@ -2851,11 +2851,11 @@ Examples:: os> SELECT TIMESTAMPDIFF(YEAR, '1997-01-01 00:00:00', '2001-03-06 00:00:00'), TIMESTAMPDIFF(SECOND, time('00:00:23'), time('00:00:00')) fetched rows / total rows = 1/1 - +---------------------------------------------------------------------+-------------------------------------------------------------+ - | TIMESTAMPDIFF(YEAR, '1997-01-01 00:00:00', '2001-03-06 00:00:00') | TIMESTAMPDIFF(SECOND, time('00:00:23'), time('00:00:00')) | - |---------------------------------------------------------------------+-------------------------------------------------------------| - | 4 | -23 | - +---------------------------------------------------------------------+-------------------------------------------------------------+ + +-------------------------------------------------------------------+-----------------------------------------------------------+ + | TIMESTAMPDIFF(YEAR, '1997-01-01 00:00:00', '2001-03-06 00:00:00') | TIMESTAMPDIFF(SECOND, time('00:00:23'), time('00:00:00')) | + |-------------------------------------------------------------------+-----------------------------------------------------------| + | 4 | -23 | + +-------------------------------------------------------------------+-----------------------------------------------------------+ TO_DAYS @@ -2874,11 +2874,11 @@ Example:: os> SELECT TO_DAYS(DATE '2008-10-07') fetched rows / total rows = 1/1 - +------------------------------+ - | TO_DAYS(DATE '2008-10-07') | - |------------------------------| - | 733687 | - +------------------------------+ + +----------------------------+ + | TO_DAYS(DATE '2008-10-07') | + |----------------------------| + | 733687 | + +----------------------------+ TO_SECONDS @@ -2898,11 +2898,11 @@ Example:: os> SELECT TO_SECONDS(DATE '2008-10-07'), TO_SECONDS(950228) fetched rows / total rows = 1/1 - +---------------------------------+----------------------+ - | TO_SECONDS(DATE '2008-10-07') | TO_SECONDS(950228) | - |---------------------------------+----------------------| - | 63390556800 | 62961148800 | - +---------------------------------+----------------------+ + +-------------------------------+--------------------+ + | TO_SECONDS(DATE '2008-10-07') | TO_SECONDS(950228) | + |-------------------------------+--------------------| + | 63390556800 | 62961148800 | + +-------------------------------+--------------------+ UNIX_TIMESTAMP @@ -2924,19 +2924,19 @@ Examples:: os> select UNIX_TIMESTAMP(20771122143845) fetched rows / total rows = 1/1 - +----------------------------------+ - | UNIX_TIMESTAMP(20771122143845) | - |----------------------------------| - | 3404817525.0 | - +----------------------------------+ + +--------------------------------+ + | UNIX_TIMESTAMP(20771122143845) | + |--------------------------------| + | 3404817525.0 | + +--------------------------------+ os> select UNIX_TIMESTAMP(TIMESTAMP('1996-11-15 17:05:42')) fetched rows / total rows = 1/1 - +----------------------------------------------------+ - | UNIX_TIMESTAMP(TIMESTAMP('1996-11-15 17:05:42')) | - |----------------------------------------------------| - | 848077542.0 | - +----------------------------------------------------+ + +--------------------------------------------------+ + | UNIX_TIMESTAMP(TIMESTAMP('1996-11-15 17:05:42')) | + |--------------------------------------------------| + | 848077542.0 | + +--------------------------------------------------+ UTC_DATE @@ -2955,11 +2955,11 @@ Example:: > SELECT UTC_DATE(); fetched rows / total rows = 1/1 - +--------------+ - | utc_date() | - |--------------| - | 2022-10-03 | - +--------------+ + +------------+ + | utc_date() | + |------------| + | 2022-10-03 | + +------------+ UTC_TIME @@ -2978,11 +2978,11 @@ Example:: > SELECT UTC_TIME(); fetched rows / total rows = 1/1 - +--------------+ - | utc_time() | - |--------------| - | 17:54:27 | - +--------------+ + +------------+ + | utc_time() | + |------------| + | 17:54:27 | + +------------+ UTC_TIMESTAMP @@ -3067,11 +3067,11 @@ Example:: os> SELECT WEEK(DATE('2008-02-20')), WEEK(DATE('2008-02-20'), 1) fetched rows / total rows = 1/1 - +----------------------------+-------------------------------+ - | WEEK(DATE('2008-02-20')) | WEEK(DATE('2008-02-20'), 1) | - |----------------------------+-------------------------------| - | 7 | 8 | - +----------------------------+-------------------------------+ + +--------------------------+-----------------------------+ + | WEEK(DATE('2008-02-20')) | WEEK(DATE('2008-02-20'), 1) | + |--------------------------+-----------------------------| + | 7 | 8 | + +--------------------------+-----------------------------+ WEEKDAY @@ -3092,11 +3092,11 @@ Example:: os> SELECT weekday('2020-08-26'), weekday('2020-08-27') fetched rows / total rows = 1/1 - +-------------------------+-------------------------+ - | weekday('2020-08-26') | weekday('2020-08-27') | - |-------------------------+-------------------------| - | 2 | 3 | - +-------------------------+-------------------------+ + +-----------------------+-----------------------+ + | weekday('2020-08-26') | weekday('2020-08-27') | + |-----------------------+-----------------------| + | 2 | 3 | + +-----------------------+-----------------------+ WEEK_OF_YEAR @@ -3116,11 +3116,11 @@ Example:: os> SELECT WEEK_OF_YEAR(DATE('2008-02-20')), WEEK_OF_YEAR(DATE('2008-02-20'), 1) fetched rows / total rows = 1/1 - +------------------------------------+---------------------------------------+ - | WEEK_OF_YEAR(DATE('2008-02-20')) | WEEK_OF_YEAR(DATE('2008-02-20'), 1) | - |------------------------------------+---------------------------------------| - | 7 | 8 | - +------------------------------------+---------------------------------------+ + +----------------------------------+-------------------------------------+ + | WEEK_OF_YEAR(DATE('2008-02-20')) | WEEK_OF_YEAR(DATE('2008-02-20'), 1) | + |----------------------------------+-------------------------------------| + | 7 | 8 | + +----------------------------------+-------------------------------------+ WEEKOFYEAR @@ -3140,11 +3140,11 @@ Example:: os> SELECT WEEKOFYEAR(DATE('2008-02-20')), WEEKOFYEAR(DATE('2008-02-20'), 1) fetched rows / total rows = 1/1 - +----------------------------------+-------------------------------------+ - | WEEKOFYEAR(DATE('2008-02-20')) | WEEKOFYEAR(DATE('2008-02-20'), 1) | - |----------------------------------+-------------------------------------| - | 7 | 8 | - +----------------------------------+-------------------------------------+ + +--------------------------------+-----------------------------------+ + | WEEKOFYEAR(DATE('2008-02-20')) | WEEKOFYEAR(DATE('2008-02-20'), 1) | + |--------------------------------+-----------------------------------| + | 7 | 8 | + +--------------------------------+-----------------------------------+ YEAR @@ -3163,11 +3163,11 @@ Example:: os> SELECT YEAR(DATE('2020-08-26')) fetched rows / total rows = 1/1 - +----------------------------+ - | YEAR(DATE('2020-08-26')) | - |----------------------------| - | 2020 | - +----------------------------+ + +--------------------------+ + | YEAR(DATE('2020-08-26')) | + |--------------------------| + | 2020 | + +--------------------------+ YEARWEEK @@ -3186,11 +3186,11 @@ Example:: os> SELECT YEARWEEK('2020-08-26'), YEARWEEK('2019-01-05', 0) fetched rows / total rows = 1/1 - +--------------------------+-----------------------------+ - | YEARWEEK('2020-08-26') | YEARWEEK('2019-01-05', 0) | - |--------------------------+-----------------------------| - | 202034 | 201852 | - +--------------------------+-----------------------------+ + +------------------------+---------------------------+ + | YEARWEEK('2020-08-26') | YEARWEEK('2019-01-05', 0) | + |------------------------+---------------------------| + | 202034 | 201852 | + +------------------------+---------------------------+ String Functions @@ -3212,11 +3212,11 @@ Example:: os> SELECT ASCII('hello') fetched rows / total rows = 1/1 - +------------------+ - | ASCII('hello') | - |------------------| - | 104 | - +------------------+ + +----------------+ + | ASCII('hello') | + |----------------| + | 104 | + +----------------+ CONCAT @@ -3235,11 +3235,11 @@ Example:: os> SELECT CONCAT('hello ', 'whole ', 'world', '!'), CONCAT('hello', 'world'), CONCAT('hello', null) fetched rows / total rows = 1/1 - +--------------------------------------------+----------------------------+-------------------------+ - | CONCAT('hello ', 'whole ', 'world', '!') | CONCAT('hello', 'world') | CONCAT('hello', null) | - |--------------------------------------------+----------------------------+-------------------------| - | hello whole world! | helloworld | null | - +--------------------------------------------+----------------------------+-------------------------+ + +------------------------------------------+--------------------------+-----------------------+ + | CONCAT('hello ', 'whole ', 'world', '!') | CONCAT('hello', 'world') | CONCAT('hello', null) | + |------------------------------------------+--------------------------+-----------------------| + | hello whole world! | helloworld | null | + +------------------------------------------+--------------------------+-----------------------+ CONCAT_WS @@ -3258,11 +3258,11 @@ Example:: os> SELECT CONCAT_WS(',', 'hello', 'world') fetched rows / total rows = 1/1 - +------------------------------------+ - | CONCAT_WS(',', 'hello', 'world') | - |------------------------------------| - | hello,world | - +------------------------------------+ + +----------------------------------+ + | CONCAT_WS(',', 'hello', 'world') | + |----------------------------------| + | hello,world | + +----------------------------------+ LEFT @@ -3278,11 +3278,11 @@ Example:: os> SELECT LEFT('helloworld', 5), LEFT('HELLOWORLD', 0) fetched rows / total rows = 1/1 - +-------------------------+-------------------------+ - | LEFT('helloworld', 5) | LEFT('HELLOWORLD', 0) | - |-------------------------+-------------------------| - | hello | | - +-------------------------+-------------------------+ + +-----------------------+-----------------------+ + | LEFT('helloworld', 5) | LEFT('HELLOWORLD', 0) | + |-----------------------+-----------------------| + | hello | | + +-----------------------+-----------------------+ LENGTH @@ -3301,11 +3301,11 @@ Example:: os> SELECT LENGTH('helloworld') fetched rows / total rows = 1/1 - +------------------------+ - | LENGTH('helloworld') | - |------------------------| - | 10 | - +------------------------+ + +----------------------+ + | LENGTH('helloworld') | + |----------------------| + | 10 | + +----------------------+ LOCATE @@ -3327,11 +3327,11 @@ Example:: os> SELECT LOCATE('world', 'helloworld'), LOCATE('world', 'helloworldworld', 7) fetched rows / total rows = 1/1 - +---------------------------------+-----------------------------------------+ - | LOCATE('world', 'helloworld') | LOCATE('world', 'helloworldworld', 7) | - |---------------------------------+-----------------------------------------| - | 6 | 11 | - +---------------------------------+-----------------------------------------+ + +-------------------------------+---------------------------------------+ + | LOCATE('world', 'helloworld') | LOCATE('world', 'helloworldworld', 7) | + |-------------------------------+---------------------------------------| + | 6 | 11 | + +-------------------------------+---------------------------------------+ LOWER @@ -3350,11 +3350,11 @@ Example:: os> SELECT LOWER('helloworld'), LOWER('HELLOWORLD') fetched rows / total rows = 1/1 - +-----------------------+-----------------------+ - | LOWER('helloworld') | LOWER('HELLOWORLD') | - |-----------------------+-----------------------| - | helloworld | helloworld | - +-----------------------+-----------------------+ + +---------------------+---------------------+ + | LOWER('helloworld') | LOWER('HELLOWORLD') | + |---------------------+---------------------| + | helloworld | helloworld | + +---------------------+---------------------+ LTRIM @@ -3373,11 +3373,11 @@ Example:: os> SELECT LTRIM(' hello'), LTRIM('hello ') fetched rows / total rows = 1/1 - +---------------------+---------------------+ - | LTRIM(' hello') | LTRIM('hello ') | - |---------------------+---------------------| - | hello | hello | - +---------------------+---------------------+ + +-------------------+-------------------+ + | LTRIM(' hello') | LTRIM('hello ') | + |-------------------+-------------------| + | hello | hello | + +-------------------+-------------------+ POSITION @@ -3398,11 +3398,11 @@ Example:: os> SELECT POSITION('world' IN 'helloworld'), POSITION('invalid' IN 'helloworld'); fetched rows / total rows = 1/1 - +-------------------------------------+---------------------------------------+ - | POSITION('world' IN 'helloworld') | POSITION('invalid' IN 'helloworld') | - |-------------------------------------+---------------------------------------| - | 6 | 0 | - +-------------------------------------+---------------------------------------+ + +-----------------------------------+-------------------------------------+ + | POSITION('world' IN 'helloworld') | POSITION('invalid' IN 'helloworld') | + |-----------------------------------+-------------------------------------| + | 6 | 0 | + +-----------------------------------+-------------------------------------+ REPLACE @@ -3421,11 +3421,11 @@ Example:: os> SELECT REPLACE('Hello World!', 'World', 'OpenSearch') fetched rows / total rows = 1/1 - +--------------------------------------------------+ - | REPLACE('Hello World!', 'World', 'OpenSearch') | - |--------------------------------------------------| - | Hello OpenSearch! | - +--------------------------------------------------+ + +------------------------------------------------+ + | REPLACE('Hello World!', 'World', 'OpenSearch') | + |------------------------------------------------| + | Hello OpenSearch! | + +------------------------------------------------+ REVERSE @@ -3444,11 +3444,11 @@ Example:: os> SELECT REVERSE('abcde'), REVERSE(null) fetched rows / total rows = 1/1 - +--------------------+-----------------+ - | REVERSE('abcde') | REVERSE(null) | - |--------------------+-----------------| - | edcba | null | - +--------------------+-----------------+ + +------------------+---------------+ + | REVERSE('abcde') | REVERSE(null) | + |------------------+---------------| + | edcba | null | + +------------------+---------------+ RIGHT @@ -3467,11 +3467,11 @@ Example:: os> SELECT RIGHT('helloworld', 5), RIGHT('HELLOWORLD', 0) fetched rows / total rows = 1/1 - +--------------------------+--------------------------+ - | RIGHT('helloworld', 5) | RIGHT('HELLOWORLD', 0) | - |--------------------------+--------------------------| - | world | | - +--------------------------+--------------------------+ + +------------------------+------------------------+ + | RIGHT('helloworld', 5) | RIGHT('HELLOWORLD', 0) | + |------------------------+------------------------| + | world | | + +------------------------+------------------------+ RTRIM @@ -3490,11 +3490,11 @@ Example:: os> SELECT RTRIM(' hello'), RTRIM('hello ') fetched rows / total rows = 1/1 - +---------------------+---------------------+ - | RTRIM(' hello') | RTRIM('hello ') | - |---------------------+---------------------| - | hello | hello | - +---------------------+---------------------+ + +-------------------+-------------------+ + | RTRIM(' hello') | RTRIM('hello ') | + |-------------------+-------------------| + | hello | hello | + +-------------------+-------------------+ SUBSTRING @@ -3515,11 +3515,11 @@ Example:: os> SELECT SUBSTRING('helloworld', 5), SUBSTRING('helloworld', 5, 3) fetched rows / total rows = 1/1 - +------------------------------+---------------------------------+ - | SUBSTRING('helloworld', 5) | SUBSTRING('helloworld', 5, 3) | - |------------------------------+---------------------------------| - | oworld | owo | - +------------------------------+---------------------------------+ + +----------------------------+-------------------------------+ + | SUBSTRING('helloworld', 5) | SUBSTRING('helloworld', 5, 3) | + |----------------------------+-------------------------------| + | oworld | owo | + +----------------------------+-------------------------------+ TRIM @@ -3536,11 +3536,11 @@ Example:: os> SELECT TRIM(' hello'), TRIM('hello ') fetched rows / total rows = 1/1 - +--------------------+--------------------+ - | TRIM(' hello') | TRIM('hello ') | - |--------------------+--------------------| - | hello | hello | - +--------------------+--------------------+ + +------------------+------------------+ + | TRIM(' hello') | TRIM('hello ') | + |------------------+------------------| + | hello | hello | + +------------------+------------------+ UPPER @@ -3559,11 +3559,11 @@ Example:: os> SELECT UPPER('helloworld'), UPPER('HELLOWORLD') fetched rows / total rows = 1/1 - +-----------------------+-----------------------+ - | UPPER('helloworld') | UPPER('HELLOWORLD') | - |-----------------------+-----------------------| - | HELLOWORLD | HELLOWORLD | - +-----------------------+-----------------------+ + +---------------------+---------------------+ + | UPPER('helloworld') | UPPER('HELLOWORLD') | + |---------------------+---------------------| + | HELLOWORLD | HELLOWORLD | + +---------------------+---------------------+ @@ -3586,31 +3586,31 @@ Example One:: os> SELECT IFNULL(123, 321), IFNULL(321, 123) fetched rows / total rows = 1/1 - +--------------------+--------------------+ - | IFNULL(123, 321) | IFNULL(321, 123) | - |--------------------+--------------------| - | 123 | 321 | - +--------------------+--------------------+ + +------------------+------------------+ + | IFNULL(123, 321) | IFNULL(321, 123) | + |------------------+------------------| + | 123 | 321 | + +------------------+------------------+ Example Two:: os> SELECT IFNULL(321, 1/0), IFNULL(1/0, 123) fetched rows / total rows = 1/1 - +--------------------+--------------------+ - | IFNULL(321, 1/0) | IFNULL(1/0, 123) | - |--------------------+--------------------| - | 321 | 123 | - +--------------------+--------------------+ + +------------------+------------------+ + | IFNULL(321, 1/0) | IFNULL(1/0, 123) | + |------------------+------------------| + | 321 | 123 | + +------------------+------------------+ Example Three:: os> SELECT IFNULL(1/0, 1/0) fetched rows / total rows = 1/1 - +--------------------+ - | IFNULL(1/0, 1/0) | - |--------------------| - | null | - +--------------------+ + +------------------+ + | IFNULL(1/0, 1/0) | + |------------------| + | null | + +------------------+ NULLIF @@ -3629,11 +3629,11 @@ Example:: os> SELECT NULLIF(123, 123), NULLIF(321, 123), NULLIF(1/0, 321), NULLIF(321, 1/0), NULLIF(1/0, 1/0) fetched rows / total rows = 1/1 - +--------------------+--------------------+--------------------+--------------------+--------------------+ - | NULLIF(123, 123) | NULLIF(321, 123) | NULLIF(1/0, 321) | NULLIF(321, 1/0) | NULLIF(1/0, 1/0) | - |--------------------+--------------------+--------------------+--------------------+--------------------| - | null | 321 | null | 321 | null | - +--------------------+--------------------+--------------------+--------------------+--------------------+ + +------------------+------------------+------------------+------------------+------------------+ + | NULLIF(123, 123) | NULLIF(321, 123) | NULLIF(1/0, 321) | NULLIF(321, 1/0) | NULLIF(1/0, 1/0) | + |------------------+------------------+------------------+------------------+------------------| + | null | 321 | null | 321 | null | + +------------------+------------------+------------------+------------------+------------------+ ISNULL @@ -3652,11 +3652,11 @@ Example:: os> SELECT ISNULL(1/0), ISNULL(123) fetched rows / total rows = 1/1 - +---------------+---------------+ - | ISNULL(1/0) | ISNULL(123) | - |---------------+---------------| - | True | False | - +---------------+---------------+ + +-------------+-------------+ + | ISNULL(1/0) | ISNULL(123) | + |-------------+-------------| + | True | False | + +-------------+-------------+ IF @@ -3677,19 +3677,19 @@ Example:: os> SELECT IF(100 > 200, '100', '200') fetched rows / total rows = 1/1 - +-------------------------------+ - | IF(100 > 200, '100', '200') | - |-------------------------------| - | 200 | - +-------------------------------+ + +-----------------------------+ + | IF(100 > 200, '100', '200') | + |-----------------------------| + | 200 | + +-----------------------------+ os> SELECT IF(200 > 100, '100', '200') fetched rows / total rows = 1/1 - +-------------------------------+ - | IF(200 > 100, '100', '200') | - |-------------------------------| - | 100 | - +-------------------------------+ + +-----------------------------+ + | IF(200 > 100, '100', '200') | + |-----------------------------| + | 100 | + +-----------------------------+ CASE @@ -3744,11 +3744,11 @@ Here are examples for simple case syntax:: ... ELSE TRIM(' Absolute three ') ... END AS func_result; fetched rows / total rows = 1/1 - +---------------+-------------------+----------------+ - | simple_case | func_case_value | func_result | - |---------------+-------------------+----------------| - | One | Absolute two | Absolute three | - +---------------+-------------------+----------------+ + +-------------+-----------------+----------------+ + | simple_case | func_case_value | func_result | + |-------------+-----------------+----------------| + | One | Absolute two | Absolute three | + +-------------+-----------------+----------------+ Here are examples for searched case syntax:: @@ -3764,11 +3764,11 @@ Here are examples for searched case syntax:: ... WHEN 'hello' = 'world' THEN 'Hello' ... END AS no_else; fetched rows / total rows = 1/1 - +-----------------+------------------+-----------+ - | single_search | multi_searches | no_else | - |-----------------+------------------+-----------| - | One | Hello | null | - +-----------------+------------------+-----------+ + +---------------+----------------+---------+ + | single_search | multi_searches | no_else | + |---------------+----------------+---------| + | One | Hello | null | + +---------------+----------------+---------+ RELEVANCE @@ -3803,22 +3803,22 @@ Example with only ``field`` and ``query`` expressions, and all other parameters os> SELECT lastname, address FROM accounts WHERE match(address, 'Street'); fetched rows / total rows = 2/2 - +------------+--------------------+ - | lastname | address | - |------------+--------------------| - | Bond | 671 Bristol Street | - | Bates | 789 Madison Street | - +------------+--------------------+ + +----------+--------------------+ + | lastname | address | + |----------+--------------------| + | Bond | 671 Bristol Street | + | Bates | 789 Madison Street | + +----------+--------------------+ Another example to show how to set custom values for the optional parameters:: os> SELECT lastname FROM accounts WHERE match(firstname, 'Hattie', operator='AND', boost=2.0); fetched rows / total rows = 1/1 - +------------+ - | lastname | - |------------| - | Bond | - +------------+ + +----------+ + | lastname | + |----------| + | Bond | + +----------+ MATCHQUERY @@ -3833,32 +3833,32 @@ Example with only ``field`` and ``query`` expressions, and all other parameters os> SELECT lastname, address FROM accounts WHERE matchquery(address, 'Street'); fetched rows / total rows = 2/2 - +------------+--------------------+ - | lastname | address | - |------------+--------------------| - | Bond | 671 Bristol Street | - | Bates | 789 Madison Street | - +------------+--------------------+ + +----------+--------------------+ + | lastname | address | + |----------+--------------------| + | Bond | 671 Bristol Street | + | Bates | 789 Madison Street | + +----------+--------------------+ Another example to show how to set custom values for the optional parameters:: os> SELECT lastname FROM accounts WHERE matchquery(firstname, 'Hattie', operator='AND', boost=2.0); fetched rows / total rows = 1/1 - +------------+ - | lastname | - |------------| - | Bond | - +------------+ + +----------+ + | lastname | + |----------| + | Bond | + +----------+ The matchquery function also supports an alternative syntax:: os> SELECT firstname FROM accounts WHERE firstname = matchquery('Hattie'); fetched rows / total rows = 1/1 - +-------------+ - | firstname | - |-------------| - | Hattie | - +-------------+ + +-----------+ + | firstname | + |-----------| + | Hattie | + +-----------+ MATCH_QUERY @@ -3873,32 +3873,32 @@ Example with only ``field`` and ``query`` expressions, and all other parameters os> SELECT lastname, address FROM accounts WHERE match_query(address, 'Street'); fetched rows / total rows = 2/2 - +------------+--------------------+ - | lastname | address | - |------------+--------------------| - | Bond | 671 Bristol Street | - | Bates | 789 Madison Street | - +------------+--------------------+ + +----------+--------------------+ + | lastname | address | + |----------+--------------------| + | Bond | 671 Bristol Street | + | Bates | 789 Madison Street | + +----------+--------------------+ Another example to show how to set custom values for the optional parameters:: os> SELECT lastname FROM accounts WHERE match_query(firstname, 'Hattie', operator='AND', boost=2.0); fetched rows / total rows = 1/1 - +------------+ - | lastname | - |------------| - | Bond | - +------------+ + +----------+ + | lastname | + |----------| + | Bond | + +----------+ The match_query function also supports an alternative syntax:: os> SELECT firstname FROM accounts WHERE firstname = match_query('Hattie'); fetched rows / total rows = 1/1 - +-------------+ - | firstname | - |-------------| - | Hattie | - +-------------+ + +-----------+ + | firstname | + |-----------| + | Hattie | + +-----------+ MATCH_PHRASE @@ -3943,19 +3943,19 @@ The match_phrase function also supports an alternative syntax:: os> SELECT firstname FROM accounts WHERE firstname = match_phrase('Hattie'); fetched rows / total rows = 1/1 - +-------------+ - | firstname | - |-------------| - | Hattie | - +-------------+ + +-----------+ + | firstname | + |-----------| + | Hattie | + +-----------+ os> SELECT firstname FROM accounts WHERE firstname = matchphrase('Hattie'); fetched rows / total rows = 1/1 - +-------------+ - | firstname | - |-------------| - | Hattie | - +-------------+ + +-----------+ + | firstname | + |-----------| + | Hattie | + +-----------+ MATCH_BOOL_PREFIX @@ -3982,22 +3982,22 @@ Example with only ``field`` and ``query`` expressions, and all other parameters os> SELECT firstname, address FROM accounts WHERE match_bool_prefix(address, 'Bristol Stre'); fetched rows / total rows = 2/2 - +-------------+--------------------+ - | firstname | address | - |-------------+--------------------| - | Hattie | 671 Bristol Street | - | Nanette | 789 Madison Street | - +-------------+--------------------+ + +-----------+--------------------+ + | firstname | address | + |-----------+--------------------| + | Hattie | 671 Bristol Street | + | Nanette | 789 Madison Street | + +-----------+--------------------+ Another example to show how to set custom values for the optional parameters:: os> SELECT firstname, address FROM accounts WHERE match_bool_prefix(address, 'Bristol Street', minimum_should_match=2); fetched rows / total rows = 1/1 - +-------------+--------------------+ - | firstname | address | - |-------------+--------------------| - | Hattie | 671 Bristol Street | - +-------------+--------------------+ + +-----------+--------------------+ + | firstname | address | + |-----------+--------------------| + | Hattie | 671 Bristol Street | + +-----------+--------------------+ MATCH_PHRASE_PREFIX @@ -4084,40 +4084,40 @@ Example with only ``fields`` and ``query`` expressions, and all other parameters os> select id, title, author from books where multi_match(['title'], 'Pooh House'); fetched rows / total rows = 2/2 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - | 2 | Winnie-the-Pooh | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + | 2 | Winnie-the-Pooh | Alan Alexander Milne | + +----+--------------------------+----------------------+ Another example to show how to set custom values for the optional parameters:: os> select id, title, author from books where multi_match(['title'], 'Pooh House', operator='AND', analyzer=default); fetched rows / total rows = 1/1 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + +----+--------------------------+----------------------+ The multi_match function also supports an alternative syntax:: os> SELECT firstname FROM accounts WHERE firstname = multi_match('Hattie'); fetched rows / total rows = 1/1 - +-------------+ - | firstname | - |-------------| - | Hattie | - +-------------+ + +-----------+ + | firstname | + |-----------| + | Hattie | + +-----------+ os> SELECT firstname FROM accounts WHERE firstname = multimatch('Hattie'); fetched rows / total rows = 1/1 - +-------------+ - | firstname | - |-------------| - | Hattie | - +-------------+ + +-----------+ + | firstname | + |-----------| + | Hattie | + +-----------+ SIMPLE_QUERY_STRING @@ -4154,22 +4154,22 @@ Example with only ``fields`` and ``query`` expressions, and all other parameters os> select id, title, author from books where simple_query_string(['title'], 'Pooh House'); fetched rows / total rows = 2/2 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - | 2 | Winnie-the-Pooh | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + | 2 | Winnie-the-Pooh | Alan Alexander Milne | + +----+--------------------------+----------------------+ Another example to show how to set custom values for the optional parameters:: os> select id, title, author from books where simple_query_string(['title'], 'Pooh House', flags='ALL', default_operator='AND'); fetched rows / total rows = 1/1 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + +----+--------------------------+----------------------+ QUERY_STRING @@ -4216,22 +4216,22 @@ Example with only ``fields`` and ``query`` expressions, and all other parameters os> select id, title, author from books where query_string(['title'], 'Pooh House'); fetched rows / total rows = 2/2 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - | 2 | Winnie-the-Pooh | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + | 2 | Winnie-the-Pooh | Alan Alexander Milne | + +----+--------------------------+----------------------+ Another example to show how to set custom values for the optional parameters:: os> select id, title, author from books where query_string(['title'], 'Pooh House', default_operator='AND'); fetched rows / total rows = 1/1 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + +----+--------------------------+----------------------+ QUERY @@ -4278,22 +4278,22 @@ Example with only ``query_expressions``, and all other parameters are set defaul os> select id, title, author from books where query('title:Pooh House'); fetched rows / total rows = 2/2 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - | 2 | Winnie-the-Pooh | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + | 2 | Winnie-the-Pooh | Alan Alexander Milne | + +----+--------------------------+----------------------+ Another example to show how to set custom values for the optional parameters:: os> select id, title, author from books where query('title:Pooh House', default_operator='AND'); fetched rows / total rows = 1/1 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + +----+--------------------------+----------------------+ SCORE @@ -4323,20 +4323,20 @@ Example boosting score:: os> select id, title, author, _score from books where score(query('title:Pooh House', default_operator='AND'), 2.0); fetched rows / total rows = 1/1 - +------+--------------------------+----------------------+-----------+ - | id | title | author | _score | - |------+--------------------------+----------------------+-----------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | 1.5884793 | - +------+--------------------------+----------------------+-----------+ + +----+--------------------------+----------------------+-----------+ + | id | title | author | _score | + |----+--------------------------+----------------------+-----------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | 1.5884793 | + +----+--------------------------+----------------------+-----------+ os> select id, title, author, _score from books where score(query('title:Pooh House', default_operator='AND'), 5.0) OR score(query('title:Winnie', default_operator='AND'), 1.5); fetched rows / total rows = 2/2 - +------+--------------------------+----------------------+-----------+ - | id | title | author | _score | - |------+--------------------------+----------------------+-----------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | 3.9711983 | - | 2 | Winnie-the-Pooh | Alan Alexander Milne | 1.1581701 | - +------+--------------------------+----------------------+-----------+ + +----+--------------------------+----------------------+-----------+ + | id | title | author | _score | + |----+--------------------------+----------------------+-----------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | 3.9711983 | + | 2 | Winnie-the-Pooh | Alan Alexander Milne | 1.1581701 | + +----+--------------------------+----------------------+-----------+ HIGHLIGHT @@ -4435,45 +4435,45 @@ Example with ``field`` and ``path`` parameters:: os> SELECT nested(message.info, message) FROM nested; fetched rows / total rows = 2/2 - +---------------------------------+ - | nested(message.info, message) | - |---------------------------------| - | a | - | b | - +---------------------------------+ + +-------------------------------+ + | nested(message.info, message) | + |-------------------------------| + | a | + | b | + +-------------------------------+ Example with ``field.*`` used in SELECT clause:: os> SELECT nested(message.*) FROM nested; fetched rows / total rows = 2/2 - +--------------------------+-----------------------------+------------------------+ - | nested(message.author) | nested(message.dayOfWeek) | nested(message.info) | - |--------------------------+-----------------------------+------------------------| - | e | 1 | a | - | f | 2 | b | - +--------------------------+-----------------------------+------------------------+ + +------------------------+---------------------------+----------------------+ + | nested(message.author) | nested(message.dayOfWeek) | nested(message.info) | + |------------------------+---------------------------+----------------------| + | e | 1 | a | + | f | 2 | b | + +------------------------+---------------------------+----------------------+ Example with ``field`` and ``path`` parameters in the SELECT and WHERE clause:: os> SELECT nested(message.info, message) FROM nested WHERE nested(message.info, message) = 'b'; fetched rows / total rows = 1/1 - +---------------------------------+ - | nested(message.info, message) | - |---------------------------------| - | b | - +---------------------------------+ + +-------------------------------+ + | nested(message.info, message) | + |-------------------------------| + | b | + +-------------------------------+ Example with ``field`` and ``path`` parameters in the SELECT and ORDER BY clause:: os> SELECT nested(message.info, message) FROM nested ORDER BY nested(message.info, message) DESC; fetched rows / total rows = 2/2 - +---------------------------------+ - | nested(message.info, message) | - |---------------------------------| - | b | - | a | - +---------------------------------+ + +-------------------------------+ + | nested(message.info, message) | + |-------------------------------| + | b | + | a | + +-------------------------------+ System Functions @@ -4495,9 +4495,9 @@ Example:: os> select typeof(DATE('2008-04-14')) as `typeof(date)`, typeof(1) as `typeof(int)`, typeof(now()) as `typeof(now())`, typeof(accounts) as `typeof(column)` from people fetched rows / total rows = 1/1 - +----------------+---------------+-----------------+------------------+ - | typeof(date) | typeof(int) | typeof(now()) | typeof(column) | - |----------------+---------------+-----------------+------------------| - | DATE | INTEGER | TIMESTAMP | OBJECT | - +----------------+---------------+-----------------+------------------+ + +--------------+-------------+---------------+----------------+ + | typeof(date) | typeof(int) | typeof(now()) | typeof(column) | + |--------------+-------------+---------------+----------------| + | DATE | INTEGER | TIMESTAMP | OBJECT | + +--------------+-------------+---------------+----------------+ diff --git a/docs/user/dql/metadata.rst b/docs/user/dql/metadata.rst index a02bcf096a..fa233020a3 100644 --- a/docs/user/dql/metadata.rst +++ b/docs/user/dql/metadata.rst @@ -36,19 +36,19 @@ SQL query:: os> SHOW TABLES LIKE '%' fetched rows / total rows = 9/9 - +----------------+---------------+-----------------+--------------+-----------+------------+--------------+-------------+-----------------------------+------------------+ - | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | - |----------------+---------------+-----------------+--------------+-----------+------------+--------------+-------------+-----------------------------+------------------| - | docTestCluster | null | .ql-datasources | BASE TABLE | null | null | null | null | null | null | - | docTestCluster | null | account2 | BASE TABLE | null | null | null | null | null | null | - | docTestCluster | null | accounts | BASE TABLE | null | null | null | null | null | null | - | docTestCluster | null | apache | BASE TABLE | null | null | null | null | null | null | - | docTestCluster | null | books | BASE TABLE | null | null | null | null | null | null | - | docTestCluster | null | nested | BASE TABLE | null | null | null | null | null | null | - | docTestCluster | null | nyc_taxi | BASE TABLE | null | null | null | null | null | null | - | docTestCluster | null | people | BASE TABLE | null | null | null | null | null | null | - | docTestCluster | null | wildcard | BASE TABLE | null | null | null | null | null | null | - +----------------+---------------+-----------------+--------------+-----------+------------+--------------+-------------+-----------------------------+------------------+ + +----------------+-------------+-----------------+------------+---------+----------+------------+-----------+---------------------------+----------------+ + | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | + |----------------+-------------+-----------------+------------+---------+----------+------------+-----------+---------------------------+----------------| + | docTestCluster | null | .ql-datasources | BASE TABLE | null | null | null | null | null | null | + | docTestCluster | null | account2 | BASE TABLE | null | null | null | null | null | null | + | docTestCluster | null | accounts | BASE TABLE | null | null | null | null | null | null | + | docTestCluster | null | apache | BASE TABLE | null | null | null | null | null | null | + | docTestCluster | null | books | BASE TABLE | null | null | null | null | null | null | + | docTestCluster | null | nested | BASE TABLE | null | null | null | null | null | null | + | docTestCluster | null | nyc_taxi | BASE TABLE | null | null | null | null | null | null | + | docTestCluster | null | people | BASE TABLE | null | null | null | null | null | null | + | docTestCluster | null | wildcard | BASE TABLE | null | null | null | null | null | null | + +----------------+-------------+-----------------+------------+---------+----------+------------+-----------+---------------------------+----------------+ Example 2: Show Specific Index Information ------------------------------------------ @@ -59,12 +59,12 @@ SQL query:: os> SHOW TABLES LIKE "acc%" fetched rows / total rows = 2/2 - +----------------+---------------+--------------+--------------+-----------+------------+--------------+-------------+-----------------------------+------------------+ - | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | - |----------------+---------------+--------------+--------------+-----------+------------+--------------+-------------+-----------------------------+------------------| - | docTestCluster | null | account2 | BASE TABLE | null | null | null | null | null | null | - | docTestCluster | null | accounts | BASE TABLE | null | null | null | null | null | null | - +----------------+---------------+--------------+--------------+-----------+------------+--------------+-------------+-----------------------------+------------------+ + +----------------+-------------+------------+------------+---------+----------+------------+-----------+---------------------------+----------------+ + | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | + |----------------+-------------+------------+------------+---------+----------+------------+-----------+---------------------------+----------------| + | docTestCluster | null | account2 | BASE TABLE | null | null | null | null | null | null | + | docTestCluster | null | accounts | BASE TABLE | null | null | null | null | null | null | + +----------------+-------------+------------+------------+---------+----------+------------+-----------+---------------------------+----------------+ Example 3: Describe Index Fields Information -------------------------------------------- @@ -75,21 +75,21 @@ SQL query:: os> DESCRIBE TABLES LIKE 'accounts' fetched rows / total rows = 11/11 - +----------------+---------------+--------------+----------------+-------------+-------------+---------------+-----------------+------------------+------------------+------------+-----------+--------------+-----------------+--------------------+---------------------+--------------------+---------------+-----------------+----------------+---------------+--------------------+--------------------+----------------------+ - | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | COLUMN_NAME | DATA_TYPE | TYPE_NAME | COLUMN_SIZE | BUFFER_LENGTH | DECIMAL_DIGITS | NUM_PREC_RADIX | NULLABLE | REMARKS | COLUMN_DEF | SQL_DATA_TYPE | SQL_DATETIME_SUB | CHAR_OCTET_LENGTH | ORDINAL_POSITION | IS_NULLABLE | SCOPE_CATALOG | SCOPE_SCHEMA | SCOPE_TABLE | SOURCE_DATA_TYPE | IS_AUTOINCREMENT | IS_GENERATEDCOLUMN | - |----------------+---------------+--------------+----------------+-------------+-------------+---------------+-----------------+------------------+------------------+------------+-----------+--------------+-----------------+--------------------+---------------------+--------------------+---------------+-----------------+----------------+---------------+--------------------+--------------------+----------------------| - | docTestCluster | null | accounts | account_number | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 0 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | firstname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 1 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | address | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 2 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | balance | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 3 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | gender | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 4 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | city | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 5 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | employer | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 6 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | state | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 7 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | age | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 8 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | email | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 9 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | lastname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 10 | | null | null | null | null | NO | | - +----------------+---------------+--------------+----------------+-------------+-------------+---------------+-----------------+------------------+------------------+------------+-----------+--------------+-----------------+--------------------+---------------------+--------------------+---------------+-----------------+----------------+---------------+--------------------+--------------------+----------------------+ + +----------------+-------------+------------+----------------+-----------+-----------+-------------+---------------+----------------+----------------+----------+---------+------------+---------------+------------------+-------------------+------------------+-------------+---------------+--------------+-------------+------------------+------------------+--------------------+ + | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | COLUMN_NAME | DATA_TYPE | TYPE_NAME | COLUMN_SIZE | BUFFER_LENGTH | DECIMAL_DIGITS | NUM_PREC_RADIX | NULLABLE | REMARKS | COLUMN_DEF | SQL_DATA_TYPE | SQL_DATETIME_SUB | CHAR_OCTET_LENGTH | ORDINAL_POSITION | IS_NULLABLE | SCOPE_CATALOG | SCOPE_SCHEMA | SCOPE_TABLE | SOURCE_DATA_TYPE | IS_AUTOINCREMENT | IS_GENERATEDCOLUMN | + |----------------+-------------+------------+----------------+-----------+-----------+-------------+---------------+----------------+----------------+----------+---------+------------+---------------+------------------+-------------------+------------------+-------------+---------------+--------------+-------------+------------------+------------------+--------------------| + | docTestCluster | null | accounts | account_number | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 0 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | firstname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 1 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | address | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 2 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | balance | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 3 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | gender | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 4 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | city | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 5 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | employer | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 6 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | state | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 7 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | age | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 8 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | email | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 9 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | lastname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 10 | | null | null | null | null | NO | | + +----------------+-------------+------------+----------------+-----------+-----------+-------------+---------------+----------------+----------------+----------+---------+------------+---------------+------------------+-------------------+------------------+-------------+---------------+--------------+-------------+------------------+------------------+--------------------+ Example 4: Describe Index With Fields Filter -------------------------------------------- @@ -100,9 +100,9 @@ SQL query:: os> DESCRIBE TABLES LIKE "accounts" COLUMNS LIKE "%name" fetched rows / total rows = 2/2 - +----------------+---------------+--------------+---------------+-------------+-------------+---------------+-----------------+------------------+------------------+------------+-----------+--------------+-----------------+--------------------+---------------------+--------------------+---------------+-----------------+----------------+---------------+--------------------+--------------------+----------------------+ - | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | COLUMN_NAME | DATA_TYPE | TYPE_NAME | COLUMN_SIZE | BUFFER_LENGTH | DECIMAL_DIGITS | NUM_PREC_RADIX | NULLABLE | REMARKS | COLUMN_DEF | SQL_DATA_TYPE | SQL_DATETIME_SUB | CHAR_OCTET_LENGTH | ORDINAL_POSITION | IS_NULLABLE | SCOPE_CATALOG | SCOPE_SCHEMA | SCOPE_TABLE | SOURCE_DATA_TYPE | IS_AUTOINCREMENT | IS_GENERATEDCOLUMN | - |----------------+---------------+--------------+---------------+-------------+-------------+---------------+-----------------+------------------+------------------+------------+-----------+--------------+-----------------+--------------------+---------------------+--------------------+---------------+-----------------+----------------+---------------+--------------------+--------------------+----------------------| - | docTestCluster | null | accounts | firstname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 1 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | lastname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 10 | | null | null | null | null | NO | | - +----------------+---------------+--------------+---------------+-------------+-------------+---------------+-----------------+------------------+------------------+------------+-----------+--------------+-----------------+--------------------+---------------------+--------------------+---------------+-----------------+----------------+---------------+--------------------+--------------------+----------------------+ + +----------------+-------------+------------+-------------+-----------+-----------+-------------+---------------+----------------+----------------+----------+---------+------------+---------------+------------------+-------------------+------------------+-------------+---------------+--------------+-------------+------------------+------------------+--------------------+ + | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | COLUMN_NAME | DATA_TYPE | TYPE_NAME | COLUMN_SIZE | BUFFER_LENGTH | DECIMAL_DIGITS | NUM_PREC_RADIX | NULLABLE | REMARKS | COLUMN_DEF | SQL_DATA_TYPE | SQL_DATETIME_SUB | CHAR_OCTET_LENGTH | ORDINAL_POSITION | IS_NULLABLE | SCOPE_CATALOG | SCOPE_SCHEMA | SCOPE_TABLE | SOURCE_DATA_TYPE | IS_AUTOINCREMENT | IS_GENERATEDCOLUMN | + |----------------+-------------+------------+-------------+-----------+-----------+-------------+---------------+----------------+----------------+----------+---------+------------+---------------+------------------+-------------------+------------------+-------------+---------------+--------------+-------------+------------------+------------------+--------------------| + | docTestCluster | null | accounts | firstname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 1 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | lastname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 10 | | null | null | null | null | NO | | + +----------------+-------------+------------+-------------+-----------+-----------+-------------+---------------+----------------+----------------+----------+---------+------------+---------------+------------------+-------------------+------------------+-------------+---------------+--------------+-------------+------------------+------------------+--------------------+ diff --git a/docs/user/dql/window.rst b/docs/user/dql/window.rst index feb2aaa44e..f0c53da055 100644 --- a/docs/user/dql/window.rst +++ b/docs/user/dql/window.rst @@ -53,14 +53,14 @@ Here is an example for ``COUNT`` function:: ... ) AS cnt ... FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+-------+ - | gender | balance | cnt | - |----------+-----------+-------| - | F | 32838 | 1 | - | M | 4180 | 1 | - | M | 5686 | 2 | - | M | 39225 | 3 | - +----------+-----------+-------+ + +--------+---------+-----+ + | gender | balance | cnt | + |--------+---------+-----| + | F | 32838 | 1 | + | M | 4180 | 1 | + | M | 5686 | 2 | + | M | 39225 | 3 | + +--------+---------+-----+ MIN --- @@ -74,14 +74,14 @@ Here is an example for ``MIN`` function:: ... ) AS cnt ... FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+-------+ - | gender | balance | cnt | - |----------+-----------+-------| - | F | 32838 | 32838 | - | M | 4180 | 4180 | - | M | 5686 | 4180 | - | M | 39225 | 4180 | - +----------+-----------+-------+ + +--------+---------+-------+ + | gender | balance | cnt | + |--------+---------+-------| + | F | 32838 | 32838 | + | M | 4180 | 4180 | + | M | 5686 | 4180 | + | M | 39225 | 4180 | + +--------+---------+-------+ MAX --- @@ -95,14 +95,14 @@ Here is an example for ``MAX`` function:: ... ) AS cnt ... FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+-------+ - | gender | balance | cnt | - |----------+-----------+-------| - | F | 32838 | 32838 | - | M | 4180 | 4180 | - | M | 5686 | 5686 | - | M | 39225 | 39225 | - +----------+-----------+-------+ + +--------+---------+-------+ + | gender | balance | cnt | + |--------+---------+-------| + | F | 32838 | 32838 | + | M | 4180 | 4180 | + | M | 5686 | 5686 | + | M | 39225 | 39225 | + +--------+---------+-------+ AVG --- @@ -116,14 +116,14 @@ Here is an example for ``AVG`` function:: ... ) AS cnt ... FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+--------------------+ - | gender | balance | cnt | - |----------+-----------+--------------------| - | F | 32838 | 32838.0 | - | M | 4180 | 4180.0 | - | M | 5686 | 4933.0 | - | M | 39225 | 16363.666666666666 | - +----------+-----------+--------------------+ + +--------+---------+--------------------+ + | gender | balance | cnt | + |--------+---------+--------------------| + | F | 32838 | 32838.0 | + | M | 4180 | 4180.0 | + | M | 5686 | 4933.0 | + | M | 39225 | 16363.666666666666 | + +--------+---------+--------------------+ SUM --- @@ -137,14 +137,14 @@ Here is an example for ``SUM`` function:: ... ) AS cnt ... FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+-------+ - | gender | balance | cnt | - |----------+-----------+-------| - | F | 32838 | 32838 | - | M | 4180 | 4180 | - | M | 5686 | 9866 | - | M | 39225 | 49091 | - +----------+-----------+-------+ + +--------+---------+-------+ + | gender | balance | cnt | + |--------+---------+-------| + | F | 32838 | 32838 | + | M | 4180 | 4180 | + | M | 5686 | 9866 | + | M | 39225 | 49091 | + +--------+---------+-------+ STDDEV_POP ---------- @@ -158,14 +158,14 @@ Here is an example for ``STDDEV_POP`` function:: ... ) AS val ... FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+--------------------+ - | gender | balance | val | - |----------+-----------+--------------------| - | F | 32838 | 0.0 | - | M | 4180 | 0.0 | - | M | 5686 | 753.0 | - | M | 39225 | 16177.091422406222 | - +----------+-----------+--------------------+ + +--------+---------+--------------------+ + | gender | balance | val | + |--------+---------+--------------------| + | F | 32838 | 0.0 | + | M | 4180 | 0.0 | + | M | 5686 | 753.0 | + | M | 39225 | 16177.091422406222 | + +--------+---------+--------------------+ STDDEV_SAMP ----------- @@ -179,14 +179,14 @@ Here is an example for ``STDDEV_SAMP`` function:: ... ) AS val ... FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+--------------------+ - | gender | balance | val | - |----------+-----------+--------------------| - | F | 32838 | 0.0 | - | M | 4180 | 0.0 | - | M | 5686 | 1064.9028124669405 | - | M | 39225 | 19812.809753624886 | - +----------+-----------+--------------------+ + +--------+---------+--------------------+ + | gender | balance | val | + |--------+---------+--------------------| + | F | 32838 | 0.0 | + | M | 4180 | 0.0 | + | M | 5686 | 1064.9028124669405 | + | M | 39225 | 19812.809753624886 | + +--------+---------+--------------------+ VAR_POP ------- @@ -200,14 +200,14 @@ Here is an example for ``SUM`` function:: ... ) AS val ... FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+--------------------+ - | gender | balance | val | - |----------+-----------+--------------------| - | F | 32838 | 0.0 | - | M | 4180 | 0.0 | - | M | 5686 | 567009.0 | - | M | 39225 | 261698286.88888893 | - +----------+-----------+--------------------+ + +--------+---------+--------------------+ + | gender | balance | val | + |--------+---------+--------------------| + | F | 32838 | 0.0 | + | M | 4180 | 0.0 | + | M | 5686 | 567009.0 | + | M | 39225 | 261698286.88888893 | + +--------+---------+--------------------+ VAR_SAMP -------- @@ -221,14 +221,14 @@ Here is an example for ``SUM`` function:: ... ) AS val ... FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+-------------------+ - | gender | balance | val | - |----------+-----------+-------------------| - | F | 32838 | 0.0 | - | M | 4180 | 0.0 | - | M | 5686 | 1134018.0 | - | M | 39225 | 392547430.3333334 | - +----------+-----------+-------------------+ + +--------+---------+-------------------+ + | gender | balance | val | + |--------+---------+-------------------| + | F | 32838 | 0.0 | + | M | 4180 | 0.0 | + | M | 5686 | 1134018.0 | + | M | 39225 | 392547430.3333334 | + +--------+---------+-------------------+ Ranking Functions @@ -248,14 +248,14 @@ ROW_NUMBER os> SELECT gender, balance, ROW_NUMBER() OVER(PARTITION BY gender ORDER BY balance) AS num FROM accounts; fetched rows / total rows = 4/4 - +----------+-----------+-------+ - | gender | balance | num | - |----------+-----------+-------| - | F | 32838 | 1 | - | M | 4180 | 1 | - | M | 5686 | 2 | - | M | 39225 | 3 | - +----------+-----------+-------+ + +--------+---------+-----+ + | gender | balance | num | + |--------+---------+-----| + | F | 32838 | 1 | + | M | 4180 | 1 | + | M | 5686 | 2 | + | M | 39225 | 3 | + +--------+---------+-----+ Similarly as regular ``ORDER BY`` clause, you can specify null ordering by ``NULLS FIRST`` or ``NULLS LAST`` which has exactly same behavior:: @@ -267,14 +267,14 @@ Similarly as regular ``ORDER BY`` clause, you can specify null ordering by ``NUL ... FROM accounts ... ORDER BY employer NULLS LAST; fetched rows / total rows = 4/4 - +------------+-------+ - | employer | num | - |------------+-------| - | Netagy | 1 | - | Pyrami | 2 | - | Quility | 3 | - | null | 4 | - +------------+-------+ + +----------+-----+ + | employer | num | + |----------+-----| + | Netagy | 1 | + | Pyrami | 2 | + | Quility | 3 | + | null | 4 | + +----------+-----+ RANK ---- @@ -283,14 +283,14 @@ RANK os> SELECT gender, RANK() OVER(ORDER BY gender DESC) AS rnk FROM accounts; fetched rows / total rows = 4/4 - +----------+-------+ - | gender | rnk | - |----------+-------| - | M | 1 | - | M | 1 | - | M | 1 | - | F | 4 | - +----------+-------+ + +--------+-----+ + | gender | rnk | + |--------+-----| + | M | 1 | + | M | 1 | + | M | 1 | + | F | 4 | + +--------+-----+ DENSE_RANK @@ -300,12 +300,12 @@ Similarly as ``RANK``, ``DENSE_RANK`` function also assigns a rank to each row. os> SELECT gender, DENSE_RANK() OVER(ORDER BY gender DESC) AS rnk FROM accounts; fetched rows / total rows = 4/4 - +----------+-------+ - | gender | rnk | - |----------+-------| - | M | 1 | - | M | 1 | - | M | 1 | - | F | 2 | - +----------+-------+ + +--------+-----+ + | gender | rnk | + |--------+-----| + | M | 1 | + | M | 1 | + | M | 1 | + | F | 2 | + +--------+-----+ diff --git a/docs/user/general/comments.rst b/docs/user/general/comments.rst index ab959da342..536843695e 100644 --- a/docs/user/general/comments.rst +++ b/docs/user/general/comments.rst @@ -26,11 +26,11 @@ A single-line comment starts with either ``#`` or ``--``. All characters in the ... -- comments ... 123; -- comments fetched rows / total rows = 1/1 - +-------+ - | 123 | - |-------| - | 123 | - +-------+ + +-----+ + | 123 | + |-----| + | 123 | + +-----+ Note that double-dash style requires at least one whitespace followed. @@ -48,10 +48,10 @@ A block comment is enclosed within ``/*`` and ``*/`` across one or multiple line ... /* comments */ ... 123; fetched rows / total rows = 1/1 - +-------+ - | 123 | - |-------| - | 123 | - +-------+ + +-----+ + | 123 | + |-----| + | 123 | + +-----+ Additionally, ``/*! ... */`` is supported though ignored for now. This may be used to support optimization hints in future. diff --git a/docs/user/general/datatypes.rst b/docs/user/general/datatypes.rst index 042e97396e..f18b5b716a 100644 --- a/docs/user/general/datatypes.rst +++ b/docs/user/general/datatypes.rst @@ -188,11 +188,11 @@ Here are a few examples for implicit type conversion:: ... 'True' = true, ... DATE('2021-06-10') < '2021-06-11'; fetched rows / total rows = 1/1 - +-----------+-----------------+-------------------------------------+ - | 1 = 1.0 | 'True' = true | DATE('2021-06-10') < '2021-06-11' | - |-----------+-----------------+-------------------------------------| - | True | True | True | - +-----------+-----------------+-------------------------------------+ + +---------+---------------+-----------------------------------+ + | 1 = 1.0 | 'True' = true | DATE('2021-06-10') < '2021-06-11' | + |---------+---------------+-----------------------------------| + | True | True | True | + +---------+---------------+-----------------------------------+ Here are a few examples for explicit type conversion:: @@ -201,11 +201,11 @@ Here are a few examples for explicit type conversion:: ... CAST(1.2 AS STRING), ... CAST('2021-06-10 00:00:00' AS TIMESTAMP); fetched rows / total rows = 1/1 - +---------------------+-----------------------+--------------------------------------------+ - | CAST(true AS INT) | CAST(1.2 AS STRING) | CAST('2021-06-10 00:00:00' AS TIMESTAMP) | - |---------------------+-----------------------+--------------------------------------------| - | 1 | 1.2 | 2021-06-10 00:00:00 | - +---------------------+-----------------------+--------------------------------------------+ + +-------------------+---------------------+------------------------------------------+ + | CAST(true AS INT) | CAST(1.2 AS STRING) | CAST('2021-06-10 00:00:00' AS TIMESTAMP) | + |-------------------+---------------------+------------------------------------------| + | 1 | 1.2 | 2021-06-10 00:00:00 | + +-------------------+---------------------+------------------------------------------+ Undefined Data Type =================== @@ -216,11 +216,11 @@ Here are examples for NULL literal and expressions with NULL literal involved:: os> SELECT NULL, NULL = NULL, 1 + NULL, LENGTH(NULL); fetched rows / total rows = 1/1 - +--------+---------------+------------+----------------+ - | NULL | NULL = NULL | 1 + NULL | LENGTH(NULL) | - |--------+---------------+------------+----------------| - | null | null | null | null | - +--------+---------------+------------+----------------+ + +------+-------------+----------+--------------+ + | NULL | NULL = NULL | 1 + NULL | LENGTH(NULL) | + |------+-------------+----------+--------------| + | null | null | null | null | + +------+-------------+----------+--------------+ Numeric Data Types @@ -318,11 +318,11 @@ A string can also represent and be converted to date and time types (except to i ... '2021-06-18' < DATE('2021-06-17'), ... '10:20:00' <= TIME('11:00:00'); fetched rows / total rows = 1/1 - +------------------------------------------------------------+-------------------------------------+----------------------------------+ - | TIMESTAMP('2021-06-17 00:00:00') = '2021-06-17 00:00:00' | '2021-06-18' < DATE('2021-06-17') | '10:20:00' <= TIME('11:00:00') | - |------------------------------------------------------------+-------------------------------------+----------------------------------| - | True | False | True | - +------------------------------------------------------------+-------------------------------------+----------------------------------+ + +----------------------------------------------------------+-----------------------------------+--------------------------------+ + | TIMESTAMP('2021-06-17 00:00:00') = '2021-06-17 00:00:00' | '2021-06-18' < DATE('2021-06-17') | '10:20:00' <= TIME('11:00:00') | + |----------------------------------------------------------+-----------------------------------+--------------------------------| + | True | False | True | + +----------------------------------------------------------+-----------------------------------+--------------------------------+ Please, see `more examples here <../dql/expressions.rst#toc-entry-15>`_. @@ -449,11 +449,11 @@ A string is a sequence of characters enclosed in either single or double quotes. os> SELECT 'hello', "world", '"hello"', "'world'", '''hello''', """world""", 'I\'m', 'I''m', "I\"m" fetched rows / total rows = 1/1 - +-----------+-----------+-------------+-------------+---------------+---------------+----------+----------+----------+ - | 'hello' | "world" | '"hello"' | "'world'" | '''hello''' | """world""" | 'I\'m' | 'I''m' | "I\"m" | - |-----------+-----------+-------------+-------------+---------------+---------------+----------+----------+----------| - | hello | world | "hello" | 'world' | 'hello' | "world" | I'm | I'm | I"m | - +-----------+-----------+-------------+-------------+---------------+---------------+----------+----------+----------+ + +---------+---------+-----------+-----------+-------------+-------------+--------+--------+--------+ + | 'hello' | "world" | '"hello"' | "'world'" | '''hello''' | """world""" | 'I\'m' | 'I''m' | "I\"m" | + |---------+---------+-----------+-----------+-------------+-------------+--------+--------+--------| + | hello | world | "hello" | 'world' | 'hello' | "world" | I'm | I'm | I"m | + +---------+---------+-----------+-----------+-------------+-------------+--------+--------+--------+ Boolean Data Types ================== @@ -464,8 +464,8 @@ A boolean can be represented by constant value ``TRUE`` or ``FALSE``. Besides, c ... true, FALSE, ... CAST('TRUE' AS boolean), CAST('false' AS boolean); fetched rows / total rows = 1/1 - +--------+---------+---------------------------+----------------------------+ - | true | FALSE | CAST('TRUE' AS boolean) | CAST('false' AS boolean) | - |--------+---------+---------------------------+----------------------------| - | True | False | True | False | - +--------+---------+---------------------------+----------------------------+ + +------+-------+-------------------------+--------------------------+ + | true | FALSE | CAST('TRUE' AS boolean) | CAST('false' AS boolean) | + |------+-------+-------------------------+--------------------------| + | True | False | True | False | + +------+-------+-------------------------+--------------------------+ diff --git a/docs/user/general/identifiers.rst b/docs/user/general/identifiers.rst index fad2fa4b23..562bf38526 100644 --- a/docs/user/general/identifiers.rst +++ b/docs/user/general/identifiers.rst @@ -40,14 +40,14 @@ Here are examples for using index pattern directly without quotes:: os> SELECT * FROM *cc*nts; fetched rows / total rows = 4/4 - +------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+ - | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | - |------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------| - | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | - | 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond | - | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | - | 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams | - +------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+ + +----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------+ + | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | + |----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------| + | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | + | 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond | + | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | + | 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams | + +----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------+ Delimited Identifiers @@ -76,14 +76,14 @@ Here are examples for quoting an index name by back ticks:: os> SELECT * FROM `accounts`; fetched rows / total rows = 4/4 - +------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+ - | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | - |------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------| - | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | - | 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond | - | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | - | 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams | - +------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+ + +----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------+ + | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | + |----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------| + | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | + | 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond | + | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | + | 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams | + +----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------+ Case Sensitivity @@ -121,23 +121,23 @@ The first example is to show a column name qualified by full table name original os> SELECT city, accounts.age, ABS(accounts.balance) FROM accounts WHERE accounts.age < 30; fetched rows / total rows = 1/1 - +--------+-------+-------------------------+ - | city | age | ABS(accounts.balance) | - |--------+-------+-------------------------| - | Nogal | 28 | 32838 | - +--------+-------+-------------------------+ + +-------+-----+-----------------------+ + | city | age | ABS(accounts.balance) | + |-------+-----+-----------------------| + | Nogal | 28 | 32838 | + +-------+-----+-----------------------+ The second example is to show a field name qualified by index alias specified. Similarly, the alias qualifier is optional in this case:: os> SELECT city, acc.age, ABS(acc.balance) FROM accounts AS acc WHERE acc.age > 30; fetched rows / total rows = 3/3 - +--------+-------+--------------------+ - | city | age | ABS(acc.balance) | - |--------+-------+--------------------| - | Brogan | 32 | 39225 | - | Dante | 36 | 5686 | - | Orick | 33 | 4180 | - +--------+-------+--------------------+ + +--------+-----+------------------+ + | city | age | ABS(acc.balance) | + |--------+-----+------------------| + | Brogan | 32 | 39225 | + | Dante | 36 | 5686 | + | Orick | 33 | 4180 | + +--------+-----+------------------+ Note that in both examples above, the qualifier is removed in response. This happens only when identifiers selected is a simple field name. In other cases, expressions rather than an atom field, the column name in response is exactly the same as the text in ``SELECT``clause. @@ -160,22 +160,22 @@ Query wildcard indices:: os> SELECT count(*) as cnt FROM acc*; fetched rows / total rows = 1/1 - +-------+ - | cnt | - |-------| - | 5 | - +-------+ + +-----+ + | cnt | + |-----| + | 5 | + +-----+ Query delimited multiple indices seperated by ``,``:: os> SELECT count(*) as cnt FROM `accounts,account2`; fetched rows / total rows = 1/1 - +-------+ - | cnt | - |-------| - | 5 | - +-------+ + +-----+ + | cnt | + |-----| + | 5 | + +-----+ diff --git a/docs/user/general/values.rst b/docs/user/general/values.rst index 178609f175..f675b42e75 100644 --- a/docs/user/general/values.rst +++ b/docs/user/general/values.rst @@ -19,14 +19,14 @@ Here is an example, Nanette doesn't have email field and Dail has employer filed os> SELECT firstname, employer, email FROM accounts; fetched rows / total rows = 4/4 - +-------------+------------+-----------------------+ - | firstname | employer | email | - |-------------+------------+-----------------------| - | Amber | Pyrami | amberduke@pyrami.com | - | Hattie | Netagy | hattiebond@netagy.com | - | Nanette | Quility | null | - | Dale | null | daleadams@boink.com | - +-------------+------------+-----------------------+ + +-----------+----------+-----------------------+ + | firstname | employer | email | + |-----------+----------+-----------------------| + | Amber | Pyrami | amberduke@pyrami.com | + | Hattie | Netagy | hattiebond@netagy.com | + | Nanette | Quility | null | + | Dale | null | daleadams@boink.com | + +-----------+----------+-----------------------+ General NULL and MISSING Values Handling @@ -37,14 +37,14 @@ Here is an example:: os> SELECT firstname, employer LIKE 'Quility', email LIKE '%com' FROM accounts; fetched rows / total rows = 4/4 - +-------------+---------------------------+---------------------+ - | firstname | employer LIKE 'Quility' | email LIKE '%com' | - |-------------+---------------------------+---------------------| - | Amber | False | True | - | Hattie | False | True | - | Nanette | True | null | - | Dale | null | True | - +-------------+---------------------------+---------------------+ + +-----------+-------------------------+-------------------+ + | firstname | employer LIKE 'Quility' | email LIKE '%com' | + |-----------+-------------------------+-------------------| + | Amber | False | True | + | Hattie | False | True | + | Nanette | True | null | + | Dale | null | True | + +-----------+-------------------------+-------------------+ Special NULL and MISSING Values Handling ---------------------------------------- diff --git a/docs/user/ppl/admin/connectors/prometheus_connector.rst b/docs/user/ppl/admin/connectors/prometheus_connector.rst index 1dfe6cda22..812df4f894 100644 --- a/docs/user/ppl/admin/connectors/prometheus_connector.rst +++ b/docs/user/ppl/admin/connectors/prometheus_connector.rst @@ -87,16 +87,16 @@ Sample Example:: > source = my_prometheus.prometheus_http_requests_total; - +------------+------------------------+--------------------------------+---------------+-------------+-------------+ - | @value | @timestamp | handler | code | instance | job | - |------------+------------------------+--------------------------------+---------------+-------------+-------------| - | 5 | "2022-11-03 07:18:14" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 3 | "2022-11-03 07:18:24" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 7 | "2022-11-03 07:18:34" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 2 | "2022-11-03 07:18:44" | "/-/ready" | 400 | 192.15.2.1 | prometheus | - | 9 | "2022-11-03 07:18:54" | "/-/promql" | 400 | 192.15.2.1 | prometheus | - | 11 | "2022-11-03 07:18:64" |"/-/metrics" | 500 | 192.15.2.1 | prometheus | - +------------+------------------------+--------------------------------+---------------+-------------+-------------+ + +--------+-----------------------+--------------+------+------------+------------+ + | @value | @timestamp | handler | code | instance | job | + |--------+-----------------------+--------------+------+------------+------------| + | 5 | "2022-11-03 07:18:14" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 3 | "2022-11-03 07:18:24" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 7 | "2022-11-03 07:18:34" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 2 | "2022-11-03 07:18:44" | "/-/ready" | 400 | 192.15.2.1 | prometheus | + | 9 | "2022-11-03 07:18:54" | "/-/promql" | 400 | 192.15.2.1 | prometheus | + | 11 | "2022-11-03 07:18:64" | "/-/metrics" | 500 | 192.15.2.1 | prometheus | + +--------+-----------------------+--------------+------+------------+------------+ @@ -119,30 +119,30 @@ Example queries 1. Metric Selection Query:: > source = my_prometheus.prometheus_http_requests_total - +------------+------------------------+--------------------------------+---------------+-------------+-------------+ - | @value | @timestamp | handler | code | instance | job | - |------------+------------------------+--------------------------------+---------------+-------------+-------------| - | 5 | "2022-11-03 07:18:14" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 3 | "2022-11-03 07:18:24" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 7 | "2022-11-03 07:18:34" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 2 | "2022-11-03 07:18:44" | "/-/ready" | 400 | 192.15.2.1 | prometheus | - | 9 | "2022-11-03 07:18:54" | "/-/promql" | 400 | 192.15.2.1 | prometheus | - | 11 | "2022-11-03 07:18:64" |"/-/metrics" | 500 | 192.15.2.1 | prometheus | - +------------+------------------------+--------------------------------+---------------+-------------+-------------+ + +--------+-----------------------+--------------+------+------------+------------+ + | @value | @timestamp | handler | code | instance | job | + |--------+-----------------------+--------------+------+------------+------------| + | 5 | "2022-11-03 07:18:14" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 3 | "2022-11-03 07:18:24" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 7 | "2022-11-03 07:18:34" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 2 | "2022-11-03 07:18:44" | "/-/ready" | 400 | 192.15.2.1 | prometheus | + | 9 | "2022-11-03 07:18:54" | "/-/promql" | 400 | 192.15.2.1 | prometheus | + | 11 | "2022-11-03 07:18:64" | "/-/metrics" | 500 | 192.15.2.1 | prometheus | + +--------+-----------------------+--------------+------+------------+------------+ 2. Metric Selecting Query with specific dimensions:: > source = my_prometheus.prometheus_http_requests_total | where handler='/-/ready' and code='200' - +------------+------------------------+--------------------------------+---------------+-------------+-------------+ - | @value | @timestamp | handler | code | instance | job | - |------------+------------------------+--------------------------------+---------------+-------------+-------------| - | 5 | "2022-11-03 07:18:14" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 3 | "2022-11-03 07:18:24" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 7 | "2022-11-03 07:18:34" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 2 | "2022-11-03 07:18:44" | "/-/ready" | 200 | 192.15.2.1 | prometheus | - | 9 | "2022-11-03 07:18:54" | "/-/ready" | 200 | 192.15.2.1 | prometheus | - | 11 | "2022-11-03 07:18:64" | "/-/ready" | 200 | 192.15.2.1 | prometheus | - +------------+------------------------+--------------------------------+---------------+-------------+-------------+ + +--------+-----------------------+------------+------+------------+------------+ + | @value | @timestamp | handler | code | instance | job | + |--------+-----------------------+------------+------+------------+------------| + | 5 | "2022-11-03 07:18:14" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 3 | "2022-11-03 07:18:24" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 7 | "2022-11-03 07:18:34" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 2 | "2022-11-03 07:18:44" | "/-/ready" | 200 | 192.15.2.1 | prometheus | + | 9 | "2022-11-03 07:18:54" | "/-/ready" | 200 | 192.15.2.1 | prometheus | + | 11 | "2022-11-03 07:18:64" | "/-/ready" | 200 | 192.15.2.1 | prometheus | + +--------+-----------------------+------------+------+------------+------------+ 3. Average aggregation on a metric:: @@ -199,16 +199,16 @@ PromQL Support for prometheus Connector Example:: > source=my_prometheus.query_range('prometheus_http_requests_total', 1686694425, 1686700130, 14) - +------------+------------------------+--------------------------------+---------------+-------------+-------------+ - | @value | @timestamp | handler | code | instance | job | - |------------+------------------------+--------------------------------+---------------+-------------+-------------| - | 5 | "2022-11-03 07:18:14" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 3 | "2022-11-03 07:18:24" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 7 | "2022-11-03 07:18:34" | "/-/ready" | 200 | 192.15.1.1 | prometheus | - | 2 | "2022-11-03 07:18:44" | "/-/ready" | 400 | 192.15.2.1 | prometheus | - | 9 | "2022-11-03 07:18:54" | "/-/promql" | 400 | 192.15.2.1 | prometheus | - | 11 | "2022-11-03 07:18:64" |"/-/metrics" | 500 | 192.15.2.1 | prometheus | - +------------+------------------------+--------------------------------+---------------+-------------+-------------+ + +--------+-----------------------+--------------+------+------------+------------+ + | @value | @timestamp | handler | code | instance | job | + |--------+-----------------------+--------------+------+------------+------------| + | 5 | "2022-11-03 07:18:14" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 3 | "2022-11-03 07:18:24" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 7 | "2022-11-03 07:18:34" | "/-/ready" | 200 | 192.15.1.1 | prometheus | + | 2 | "2022-11-03 07:18:44" | "/-/ready" | 400 | 192.15.2.1 | prometheus | + | 9 | "2022-11-03 07:18:54" | "/-/promql" | 400 | 192.15.2.1 | prometheus | + | 11 | "2022-11-03 07:18:64" | "/-/metrics" | 500 | 192.15.2.1 | prometheus | + +--------+-----------------------+--------------+------+------------+------------+ Prometheus Connector Table Functions diff --git a/docs/user/ppl/admin/cross_cluster_search.rst b/docs/user/ppl/admin/cross_cluster_search.rst index f57ea288e8..4b267a9340 100644 --- a/docs/user/ppl/admin/cross_cluster_search.rst +++ b/docs/user/ppl/admin/cross_cluster_search.rst @@ -40,14 +40,14 @@ Example PPL query:: os> source=my_remote_cluster:accounts; fetched rows / total rows = 4/4 - +------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+ - | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | - |------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------| - | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | - | 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond | - | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | - | 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams | - +------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+ + +----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------+ + | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | + |----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------| + | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | + | 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond | + | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | + | 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams | + +----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------+ Limitation diff --git a/docs/user/ppl/cmd/ad.rst b/docs/user/ppl/cmd/ad.rst index 103c7f7483..5d7a572c96 100644 --- a/docs/user/ppl/cmd/ad.rst +++ b/docs/user/ppl/cmd/ad.rst @@ -50,11 +50,11 @@ PPL query:: > source=nyc_taxi | fields value, timestamp | AD time_field='timestamp' | where value=10844.0 fetched rows / total rows = 1/1 - +---------+---------------------+---------+-----------------+ - | value | timestamp | score | anomaly_grade | - |---------+---------------------+---------+-----------------| - | 10844.0 | 2014-07-01 00:00:00 | 0.0 | 0.0 | - +---------+---------------------+---------+-----------------+ + +---------+---------------------+-------+---------------+ + | value | timestamp | score | anomaly_grade | + |---------+---------------------+-------+---------------| + | 10844.0 | 2014-07-01 00:00:00 | 0.0 | 0.0 | + +---------+---------------------+-------+---------------+ Example 2: Detecting events in New York City from taxi ridership data with time-series data independently with each category ============================================================================================================================ @@ -65,12 +65,12 @@ PPL query:: > source=nyc_taxi | fields category, value, timestamp | AD time_field='timestamp' category_field='category' | where value=10844.0 or value=6526.0 fetched rows / total rows = 2/2 - +------------+---------+---------------------+---------+-----------------+ - | category | value | timestamp | score | anomaly_grade | - |------------+---------+---------------------+---------+-----------------| - | night | 10844.0 | 2014-07-01 00:00:00 | 0.0 | 0.0 | - | day | 6526.0 | 2014-07-01 06:00:00 | 0.0 | 0.0 | - +------------+---------+---------------------+---------+-----------------+ + +----------+---------+---------------------+-------+---------------+ + | category | value | timestamp | score | anomaly_grade | + |----------+---------+---------------------+-------+---------------| + | night | 10844.0 | 2014-07-01 00:00:00 | 0.0 | 0.0 | + | day | 6526.0 | 2014-07-01 06:00:00 | 0.0 | 0.0 | + +----------+---------+---------------------+-------+---------------+ Example 3: Detecting events in New York City from taxi ridership data with non-time-series data @@ -82,11 +82,11 @@ PPL query:: > source=nyc_taxi | fields value | AD | where value=10844.0 fetched rows / total rows = 1/1 - +---------+---------+-------------+ - | value | score | anomalous | - |---------+---------+-------------| - | 10844.0 | 0.0 | False | - +---------+---------+-------------+ + +---------+-------+-----------+ + | value | score | anomalous | + |---------+-------+-----------| + | 10844.0 | 0.0 | False | + +---------+-------+-----------+ Example 4: Detecting events in New York City from taxi ridership data with non-time-series data independently with each category ================================================================================================================================ @@ -97,9 +97,9 @@ PPL query:: > source=nyc_taxi | fields category, value | AD category_field='category' | where value=10844.0 or value=6526.0 fetched rows / total rows = 2/2 - +------------+---------+---------+-------------+ - | category | value | score | anomalous | - |------------+---------+---------+-------------| - | night | 10844.0 | 0.0 | False | - | day | 6526.0 | 0.0 | False | - +------------+---------+---------+-------------+ + +----------+---------+-------+-----------+ + | category | value | score | anomalous | + |----------+---------+-------+-----------| + | night | 10844.0 | 0.0 | False | + | day | 6526.0 | 0.0 | False | + +----------+---------+-------+-----------+ diff --git a/docs/user/ppl/cmd/dedup.rst b/docs/user/ppl/cmd/dedup.rst index ebceb9e0bd..362d1637f7 100644 --- a/docs/user/ppl/cmd/dedup.rst +++ b/docs/user/ppl/cmd/dedup.rst @@ -34,12 +34,12 @@ PPL query:: os> source=accounts | dedup gender | fields account_number, gender; fetched rows / total rows = 2/2 - +------------------+----------+ - | account_number | gender | - |------------------+----------| - | 1 | M | - | 13 | F | - +------------------+----------+ + +----------------+--------+ + | account_number | gender | + |----------------+--------| + | 1 | M | + | 13 | F | + +----------------+--------+ Example 2: Keep 2 duplicates documents ====================================== @@ -50,13 +50,13 @@ PPL query:: os> source=accounts | dedup 2 gender | fields account_number, gender; fetched rows / total rows = 3/3 - +------------------+----------+ - | account_number | gender | - |------------------+----------| - | 1 | M | - | 6 | M | - | 13 | F | - +------------------+----------+ + +----------------+--------+ + | account_number | gender | + |----------------+--------| + | 1 | M | + | 6 | M | + | 13 | F | + +----------------+--------+ Example 3: Keep or Ignore the empty field by default ============================================ @@ -67,14 +67,14 @@ PPL query:: os> source=accounts | dedup email keepempty=true | fields account_number, email; fetched rows / total rows = 4/4 - +------------------+-----------------------+ - | account_number | email | - |------------------+-----------------------| - | 1 | amberduke@pyrami.com | - | 6 | hattiebond@netagy.com | - | 13 | null | - | 18 | daleadams@boink.com | - +------------------+-----------------------+ + +----------------+-----------------------+ + | account_number | email | + |----------------+-----------------------| + | 1 | amberduke@pyrami.com | + | 6 | hattiebond@netagy.com | + | 13 | null | + | 18 | daleadams@boink.com | + +----------------+-----------------------+ The example show dedup the document by ignore the empty value field. @@ -83,13 +83,13 @@ PPL query:: os> source=accounts | dedup email | fields account_number, email; fetched rows / total rows = 3/3 - +------------------+-----------------------+ - | account_number | email | - |------------------+-----------------------| - | 1 | amberduke@pyrami.com | - | 6 | hattiebond@netagy.com | - | 18 | daleadams@boink.com | - +------------------+-----------------------+ + +----------------+-----------------------+ + | account_number | email | + |----------------+-----------------------| + | 1 | amberduke@pyrami.com | + | 6 | hattiebond@netagy.com | + | 18 | daleadams@boink.com | + +----------------+-----------------------+ Example 4: Dedup in consecutive document @@ -101,13 +101,13 @@ PPL query:: os> source=accounts | dedup gender consecutive=true | fields account_number, gender; fetched rows / total rows = 3/3 - +------------------+----------+ - | account_number | gender | - |------------------+----------| - | 1 | M | - | 13 | F | - | 18 | M | - +------------------+----------+ + +----------------+--------+ + | account_number | gender | + |----------------+--------| + | 1 | M | + | 13 | F | + | 18 | M | + +----------------+--------+ Limitation ========== diff --git a/docs/user/ppl/cmd/describe.rst b/docs/user/ppl/cmd/describe.rst index a0ecbd3169..2b03ceda57 100644 --- a/docs/user/ppl/cmd/describe.rst +++ b/docs/user/ppl/cmd/describe.rst @@ -33,21 +33,21 @@ PPL query:: os> describe accounts; fetched rows / total rows = 11/11 - +----------------+---------------+--------------+----------------+-------------+-------------+---------------+-----------------+------------------+------------------+------------+-----------+--------------+-----------------+--------------------+---------------------+--------------------+---------------+-----------------+----------------+---------------+--------------------+--------------------+----------------------+ - | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | COLUMN_NAME | DATA_TYPE | TYPE_NAME | COLUMN_SIZE | BUFFER_LENGTH | DECIMAL_DIGITS | NUM_PREC_RADIX | NULLABLE | REMARKS | COLUMN_DEF | SQL_DATA_TYPE | SQL_DATETIME_SUB | CHAR_OCTET_LENGTH | ORDINAL_POSITION | IS_NULLABLE | SCOPE_CATALOG | SCOPE_SCHEMA | SCOPE_TABLE | SOURCE_DATA_TYPE | IS_AUTOINCREMENT | IS_GENERATEDCOLUMN | - |----------------+---------------+--------------+----------------+-------------+-------------+---------------+-----------------+------------------+------------------+------------+-----------+--------------+-----------------+--------------------+---------------------+--------------------+---------------+-----------------+----------------+---------------+--------------------+--------------------+----------------------| - | docTestCluster | null | accounts | account_number | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 0 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | firstname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 1 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | address | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 2 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | balance | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 3 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | gender | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 4 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | city | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 5 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | employer | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 6 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | state | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 7 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | age | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 8 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | email | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 9 | | null | null | null | null | NO | | - | docTestCluster | null | accounts | lastname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 10 | | null | null | null | null | NO | | - +----------------+---------------+--------------+----------------+-------------+-------------+---------------+-----------------+------------------+------------------+------------+-----------+--------------+-----------------+--------------------+---------------------+--------------------+---------------+-----------------+----------------+---------------+--------------------+--------------------+----------------------+ + +----------------+-------------+------------+----------------+-----------+-----------+-------------+---------------+----------------+----------------+----------+---------+------------+---------------+------------------+-------------------+------------------+-------------+---------------+--------------+-------------+------------------+------------------+--------------------+ + | TABLE_CAT | TABLE_SCHEM | TABLE_NAME | COLUMN_NAME | DATA_TYPE | TYPE_NAME | COLUMN_SIZE | BUFFER_LENGTH | DECIMAL_DIGITS | NUM_PREC_RADIX | NULLABLE | REMARKS | COLUMN_DEF | SQL_DATA_TYPE | SQL_DATETIME_SUB | CHAR_OCTET_LENGTH | ORDINAL_POSITION | IS_NULLABLE | SCOPE_CATALOG | SCOPE_SCHEMA | SCOPE_TABLE | SOURCE_DATA_TYPE | IS_AUTOINCREMENT | IS_GENERATEDCOLUMN | + |----------------+-------------+------------+----------------+-----------+-----------+-------------+---------------+----------------+----------------+----------+---------+------------+---------------+------------------+-------------------+------------------+-------------+---------------+--------------+-------------+------------------+------------------+--------------------| + | docTestCluster | null | accounts | account_number | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 0 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | firstname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 1 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | address | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 2 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | balance | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 3 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | gender | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 4 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | city | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 5 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | employer | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 6 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | state | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 7 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | age | null | long | null | null | null | 10 | 2 | null | null | null | null | null | 8 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | email | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 9 | | null | null | null | null | NO | | + | docTestCluster | null | accounts | lastname | null | text | null | null | null | 10 | 2 | null | null | null | null | null | 10 | | null | null | null | null | NO | | + +----------------+-------------+------------+----------------+-----------+-----------+-------------+---------------+----------------+----------------+----------+---------+------------+---------------+------------------+-------------------+------------------+-------------+---------------+--------------+-------------+------------------+------------------+--------------------+ Example 2: Fetch metadata with condition and filter =================================================== @@ -76,13 +76,13 @@ PPL query:: os> describe my_prometheus.prometheus_http_requests_total; fetched rows / total rows = 6/6 - +-----------------+----------------+--------------------------------+---------------+-------------+ - | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | DATA_TYPE | - |-----------------+----------------+--------------------------------+---------------+-------------| - | my_prometheus | default | prometheus_http_requests_total | handler | keyword | - | my_prometheus | default | prometheus_http_requests_total | code | keyword | - | my_prometheus | default | prometheus_http_requests_total | instance | keyword | - | my_prometheus | default | prometheus_http_requests_total | @timestamp | timestamp | - | my_prometheus | default | prometheus_http_requests_total | @value | double | - | my_prometheus | default | prometheus_http_requests_total | job | keyword | - +-----------------+----------------+--------------------------------+---------------+-------------+ + +---------------+--------------+--------------------------------+-------------+-----------+ + | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | DATA_TYPE | + |---------------+--------------+--------------------------------+-------------+-----------| + | my_prometheus | default | prometheus_http_requests_total | handler | keyword | + | my_prometheus | default | prometheus_http_requests_total | code | keyword | + | my_prometheus | default | prometheus_http_requests_total | instance | keyword | + | my_prometheus | default | prometheus_http_requests_total | @timestamp | timestamp | + | my_prometheus | default | prometheus_http_requests_total | @value | double | + | my_prometheus | default | prometheus_http_requests_total | job | keyword | + +---------------+--------------+--------------------------------+-------------+-----------+ diff --git a/docs/user/ppl/cmd/eval.rst b/docs/user/ppl/cmd/eval.rst index 48a14ae0a8..c950028674 100644 --- a/docs/user/ppl/cmd/eval.rst +++ b/docs/user/ppl/cmd/eval.rst @@ -30,14 +30,14 @@ PPL query:: os> source=accounts | eval doubleAge = age * 2 | fields age, doubleAge ; fetched rows / total rows = 4/4 - +-------+-------------+ - | age | doubleAge | - |-------+-------------| - | 32 | 64 | - | 36 | 72 | - | 28 | 56 | - | 33 | 66 | - +-------+-------------+ + +-----+-----------+ + | age | doubleAge | + |-----+-----------| + | 32 | 64 | + | 36 | 72 | + | 28 | 56 | + | 33 | 66 | + +-----+-----------+ Example 2: Override the existing field @@ -49,14 +49,14 @@ PPL query:: os> source=accounts | eval age = age + 1 | fields age ; fetched rows / total rows = 4/4 - +-------+ - | age | - |-------| - | 33 | - | 37 | - | 29 | - | 34 | - +-------+ + +-----+ + | age | + |-----| + | 33 | + | 37 | + | 29 | + | 34 | + +-----+ Example 3: Create the new field with field defined in eval ========================================================== @@ -67,14 +67,14 @@ PPL query:: os> source=accounts | eval doubleAge = age * 2, ddAge = doubleAge * 2 | fields age, doubleAge, ddAge ; fetched rows / total rows = 4/4 - +-------+-------------+---------+ - | age | doubleAge | ddAge | - |-------+-------------+---------| - | 32 | 64 | 128 | - | 36 | 72 | 144 | - | 28 | 56 | 112 | - | 33 | 66 | 132 | - +-------+-------------+---------+ + +-----+-----------+-------+ + | age | doubleAge | ddAge | + |-----+-----------+-------| + | 32 | 64 | 128 | + | 36 | 72 | 144 | + | 28 | 56 | 112 | + | 33 | 66 | 132 | + +-----+-----------+-------+ Limitation ========== diff --git a/docs/user/ppl/cmd/fields.rst b/docs/user/ppl/cmd/fields.rst index dbae5b20a4..32c3a665d7 100644 --- a/docs/user/ppl/cmd/fields.rst +++ b/docs/user/ppl/cmd/fields.rst @@ -31,14 +31,14 @@ PPL query:: os> source=accounts | fields account_number, firstname, lastname; fetched rows / total rows = 4/4 - +------------------+-------------+------------+ - | account_number | firstname | lastname | - |------------------+-------------+------------| - | 1 | Amber | Duke | - | 6 | Hattie | Bond | - | 13 | Nanette | Bates | - | 18 | Dale | Adams | - +------------------+-------------+------------+ + +----------------+-----------+----------+ + | account_number | firstname | lastname | + |----------------+-----------+----------| + | 1 | Amber | Duke | + | 6 | Hattie | Bond | + | 13 | Nanette | Bates | + | 18 | Dale | Adams | + +----------------+-----------+----------+ Example 2: Remove specified fields from result ============================================== @@ -49,12 +49,12 @@ PPL query:: os> source=accounts | fields account_number, firstname, lastname | fields - account_number ; fetched rows / total rows = 4/4 - +-------------+------------+ - | firstname | lastname | - |-------------+------------| - | Amber | Duke | - | Hattie | Bond | - | Nanette | Bates | - | Dale | Adams | - +-------------+------------+ + +-----------+----------+ + | firstname | lastname | + |-----------+----------| + | Amber | Duke | + | Hattie | Bond | + | Nanette | Bates | + | Dale | Adams | + +-----------+----------+ diff --git a/docs/user/ppl/cmd/grok.rst b/docs/user/ppl/cmd/grok.rst index 6a121c7431..35f3b0c846 100644 --- a/docs/user/ppl/cmd/grok.rst +++ b/docs/user/ppl/cmd/grok.rst @@ -72,14 +72,14 @@ PPL query:: os> source=apache | grok message '%{COMMONAPACHELOG}' | fields COMMONAPACHELOG, timestamp, response, bytes ; fetched rows / total rows = 4/4 - +-----------------------------------------------------------------------------------------------------------------------------+----------------------------+------------+---------+ - | COMMONAPACHELOG | timestamp | response | bytes | - |-----------------------------------------------------------------------------------------------------------------------------+----------------------------+------------+---------| - | 177.95.8.74 - upton5450 [28/Sep/2022:10:15:57 -0700] "HEAD /e-business/mindshare HTTP/1.0" 404 19927 | 28/Sep/2022:10:15:57 -0700 | 404 | 19927 | - | 127.45.152.6 - pouros8756 [28/Sep/2022:10:15:57 -0700] "GET /architectures/convergence/niches/mindshare HTTP/1.0" 100 28722 | 28/Sep/2022:10:15:57 -0700 | 100 | 28722 | - | 118.223.210.105 - - [28/Sep/2022:10:15:57 -0700] "PATCH /strategize/out-of-the-box HTTP/1.0" 401 27439 | 28/Sep/2022:10:15:57 -0700 | 401 | 27439 | - | 210.204.15.104 - - [28/Sep/2022:10:15:57 -0700] "POST /users HTTP/1.1" 301 9481 | 28/Sep/2022:10:15:57 -0700 | 301 | 9481 | - +-----------------------------------------------------------------------------------------------------------------------------+----------------------------+------------+---------+ + +-----------------------------------------------------------------------------------------------------------------------------+----------------------------+----------+-------+ + | COMMONAPACHELOG | timestamp | response | bytes | + |-----------------------------------------------------------------------------------------------------------------------------+----------------------------+----------+-------| + | 177.95.8.74 - upton5450 [28/Sep/2022:10:15:57 -0700] "HEAD /e-business/mindshare HTTP/1.0" 404 19927 | 28/Sep/2022:10:15:57 -0700 | 404 | 19927 | + | 127.45.152.6 - pouros8756 [28/Sep/2022:10:15:57 -0700] "GET /architectures/convergence/niches/mindshare HTTP/1.0" 100 28722 | 28/Sep/2022:10:15:57 -0700 | 100 | 28722 | + | 118.223.210.105 - - [28/Sep/2022:10:15:57 -0700] "PATCH /strategize/out-of-the-box HTTP/1.0" 401 27439 | 28/Sep/2022:10:15:57 -0700 | 401 | 27439 | + | 210.204.15.104 - - [28/Sep/2022:10:15:57 -0700] "POST /users HTTP/1.1" 301 9481 | 28/Sep/2022:10:15:57 -0700 | 301 | 9481 | + +-----------------------------------------------------------------------------------------------------------------------------+----------------------------+----------+-------+ Limitations =========== diff --git a/docs/user/ppl/cmd/head.rst b/docs/user/ppl/cmd/head.rst index 1b4599f5de..cd4aed5a54 100644 --- a/docs/user/ppl/cmd/head.rst +++ b/docs/user/ppl/cmd/head.rst @@ -30,14 +30,14 @@ PPL query:: os> source=accounts | fields firstname, age | head; fetched rows / total rows = 4/4 - +-------------+-------+ - | firstname | age | - |-------------+-------| - | Amber | 32 | - | Hattie | 36 | - | Nanette | 28 | - | Dale | 33 | - +-------------+-------+ + +-----------+-----+ + | firstname | age | + |-----------+-----| + | Amber | 32 | + | Hattie | 36 | + | Nanette | 28 | + | Dale | 33 | + +-----------+-----+ Example 2: Get first N results =========================================== @@ -48,13 +48,13 @@ PPL query:: os> source=accounts | fields firstname, age | head 3; fetched rows / total rows = 3/3 - +-------------+-------+ - | firstname | age | - |-------------+-------| - | Amber | 32 | - | Hattie | 36 | - | Nanette | 28 | - +-------------+-------+ + +-----------+-----+ + | firstname | age | + |-----------+-----| + | Amber | 32 | + | Hattie | 36 | + | Nanette | 28 | + +-----------+-----+ Example 3: Get first N results after offset M ============================================= @@ -65,13 +65,13 @@ PPL query:: os> source=accounts | fields firstname, age | head 3 from 1; fetched rows / total rows = 3/3 - +-------------+-------+ - | firstname | age | - |-------------+-------| - | Hattie | 36 | - | Nanette | 28 | - | Dale | 33 | - +-------------+-------+ + +-----------+-----+ + | firstname | age | + |-----------+-----| + | Hattie | 36 | + | Nanette | 28 | + | Dale | 33 | + +-----------+-----+ Limitation ========== diff --git a/docs/user/ppl/cmd/information_schema.rst b/docs/user/ppl/cmd/information_schema.rst index 26341d6972..4210502eda 100644 --- a/docs/user/ppl/cmd/information_schema.rst +++ b/docs/user/ppl/cmd/information_schema.rst @@ -29,11 +29,11 @@ PPL query for fetching PROMETHEUS TABLES with where clause:: os> source = my_prometheus.information_schema.tables | where TABLE_NAME='prometheus_http_requests_total' fetched rows / total rows = 1/1 - +-----------------+----------------+--------------------------------+--------------+--------+---------------------------+ - | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | UNIT | REMARKS | - |-----------------+----------------+--------------------------------+--------------+--------+---------------------------| - | my_prometheus | default | prometheus_http_requests_total | counter | | Counter of HTTP requests. | - +-----------------+----------------+--------------------------------+--------------+--------+---------------------------+ + +---------------+--------------+--------------------------------+------------+------+---------------------------+ + | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | UNIT | REMARKS | + |---------------+--------------+--------------------------------+------------+------+---------------------------| + | my_prometheus | default | prometheus_http_requests_total | counter | | Counter of HTTP requests. | + +---------------+--------------+--------------------------------+------------+------+---------------------------+ Example 2: Search tables in prometheus datasource. @@ -45,13 +45,13 @@ PPL query for searching PROMETHEUS TABLES:: os> source = my_prometheus.information_schema.tables | where LIKE(TABLE_NAME, "%http%"); fetched rows / total rows = 6/6 - +-----------------+----------------+--------------------------------------------+--------------+--------+----------------------------------------------------+ - | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | UNIT | REMARKS | - |-----------------+----------------+--------------------------------------------+--------------+--------+----------------------------------------------------| - | my_prometheus | default | prometheus_http_requests_total | counter | | Counter of HTTP requests. | - | my_prometheus | default | promhttp_metric_handler_requests_in_flight | gauge | | Current number of scrapes being served. | - | my_prometheus | default | prometheus_http_request_duration_seconds | histogram | | Histogram of latencies for HTTP requests. | - | my_prometheus | default | prometheus_sd_http_failures_total | counter | | Number of HTTP service discovery refresh failures. | - | my_prometheus | default | promhttp_metric_handler_requests_total | counter | | Total number of scrapes by HTTP status code. | - | my_prometheus | default | prometheus_http_response_size_bytes | histogram | | Histogram of response size for HTTP requests. | - +-----------------+----------------+--------------------------------------------+--------------+--------+----------------------------------------------------+ + +---------------+--------------+--------------------------------------------+------------+------+----------------------------------------------------+ + | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | UNIT | REMARKS | + |---------------+--------------+--------------------------------------------+------------+------+----------------------------------------------------| + | my_prometheus | default | prometheus_http_requests_total | counter | | Counter of HTTP requests. | + | my_prometheus | default | promhttp_metric_handler_requests_in_flight | gauge | | Current number of scrapes being served. | + | my_prometheus | default | prometheus_http_request_duration_seconds | histogram | | Histogram of latencies for HTTP requests. | + | my_prometheus | default | prometheus_sd_http_failures_total | counter | | Number of HTTP service discovery refresh failures. | + | my_prometheus | default | promhttp_metric_handler_requests_total | counter | | Total number of scrapes by HTTP status code. | + | my_prometheus | default | prometheus_http_response_size_bytes | histogram | | Histogram of response size for HTTP requests. | + +---------------+--------------+--------------------------------------------+------------+------+----------------------------------------------------+ diff --git a/docs/user/ppl/cmd/ml.rst b/docs/user/ppl/cmd/ml.rst index 2e04674c1e..a48c1ec589 100644 --- a/docs/user/ppl/cmd/ml.rst +++ b/docs/user/ppl/cmd/ml.rst @@ -56,11 +56,11 @@ PPL query:: os> source=nyc_taxi | fields value, timestamp | ml action='train' algorithm='rcf' time_field='timestamp' | where value=10844.0 fetched rows / total rows = 1/1 - +---------+---------------------+---------+-----------------+ - | value | timestamp | score | anomaly_grade | - |---------+---------------------+---------+-----------------| - | 10844.0 | 2014-07-01 00:00:00 | 0.0 | 0.0 | - +---------+---------------------+---------+-----------------+ + +---------+---------------------+-------+---------------+ + | value | timestamp | score | anomaly_grade | + |---------+---------------------+-------+---------------| + | 10844.0 | 2014-07-01 00:00:00 | 0.0 | 0.0 | + +---------+---------------------+-------+---------------+ Example 2: Detecting events in New York City from taxi ridership data with time-series data independently with each category ============================================================================================================================ @@ -71,12 +71,12 @@ PPL query:: os> source=nyc_taxi | fields category, value, timestamp | ml action='train' algorithm='rcf' time_field='timestamp' category_field='category' | where value=10844.0 or value=6526.0 fetched rows / total rows = 2/2 - +------------+---------+---------------------+---------+-----------------+ - | category | value | timestamp | score | anomaly_grade | - |------------+---------+---------------------+---------+-----------------| - | night | 10844.0 | 2014-07-01 00:00:00 | 0.0 | 0.0 | - | day | 6526.0 | 2014-07-01 06:00:00 | 0.0 | 0.0 | - +------------+---------+---------------------+---------+-----------------+ + +----------+---------+---------------------+-------+---------------+ + | category | value | timestamp | score | anomaly_grade | + |----------+---------+---------------------+-------+---------------| + | night | 10844.0 | 2014-07-01 00:00:00 | 0.0 | 0.0 | + | day | 6526.0 | 2014-07-01 06:00:00 | 0.0 | 0.0 | + +----------+---------+---------------------+-------+---------------+ Example 3: Detecting events in New York City from taxi ridership data with non-time-series data @@ -88,11 +88,11 @@ PPL query:: os> source=nyc_taxi | fields value | ml action='train' algorithm='rcf' | where value=10844.0 fetched rows / total rows = 1/1 - +---------+---------+-------------+ - | value | score | anomalous | - |---------+---------+-------------| - | 10844.0 | 0.0 | False | - +---------+---------+-------------+ + +---------+-------+-----------+ + | value | score | anomalous | + |---------+-------+-----------| + | 10844.0 | 0.0 | False | + +---------+-------+-----------+ Example 4: Detecting events in New York City from taxi ridership data with non-time-series data independently with each category ================================================================================================================================ @@ -103,12 +103,12 @@ PPL query:: os> source=nyc_taxi | fields category, value | ml action='train' algorithm='rcf' category_field='category' | where value=10844.0 or value=6526.0 fetched rows / total rows = 2/2 - +------------+---------+---------+-------------+ - | category | value | score | anomalous | - |------------+---------+---------+-------------| - | night | 10844.0 | 0.0 | False | - | day | 6526.0 | 0.0 | False | - +------------+---------+---------+-------------+ + +----------+---------+-------+-----------+ + | category | value | score | anomalous | + |----------+---------+-------+-----------| + | night | 10844.0 | 0.0 | False | + | day | 6526.0 | 0.0 | False | + +----------+---------+-------+-----------+ KMEANS ====== diff --git a/docs/user/ppl/cmd/parse.rst b/docs/user/ppl/cmd/parse.rst index 82eff8ee85..d1015cccb9 100644 --- a/docs/user/ppl/cmd/parse.rst +++ b/docs/user/ppl/cmd/parse.rst @@ -72,13 +72,13 @@ PPL query:: os> source=accounts | parse address '(?\d+) (?.+)' | where cast(streetNumber as int) > 500 | sort num(streetNumber) | fields streetNumber, street ; fetched rows / total rows = 3/3 - +----------------+----------------+ - | streetNumber | street | - |----------------+----------------| - | 671 | Bristol Street | - | 789 | Madison Street | - | 880 | Holmes Lane | - +----------------+----------------+ + +--------------+----------------+ + | streetNumber | street | + |--------------+----------------| + | 671 | Bristol Street | + | 789 | Madison Street | + | 880 | Holmes Lane | + +--------------+----------------+ Limitations =========== diff --git a/docs/user/ppl/cmd/patterns.rst b/docs/user/ppl/cmd/patterns.rst index 370404ecb6..13f08d0aa6 100644 --- a/docs/user/ppl/cmd/patterns.rst +++ b/docs/user/ppl/cmd/patterns.rst @@ -31,14 +31,14 @@ PPL query:: os> source=accounts | patterns email | fields email, patterns_field ; fetched rows / total rows = 4/4 - +-----------------------+------------------+ - | email | patterns_field | - |-----------------------+------------------| - | amberduke@pyrami.com | @. | - | hattiebond@netagy.com | @. | - | null | | - | daleadams@boink.com | @. | - +-----------------------+------------------+ + +-----------------------+----------------+ + | email | patterns_field | + |-----------------------+----------------| + | amberduke@pyrami.com | @. | + | hattiebond@netagy.com | @. | + | null | | + | daleadams@boink.com | @. | + +-----------------------+----------------+ Example 2: Extract log patterns =============================== diff --git a/docs/user/ppl/cmd/rare.rst b/docs/user/ppl/cmd/rare.rst index 35b660daa7..f6013711ae 100644 --- a/docs/user/ppl/cmd/rare.rst +++ b/docs/user/ppl/cmd/rare.rst @@ -32,12 +32,12 @@ PPL query:: os> source=accounts | rare gender; fetched rows / total rows = 2/2 - +----------+ - | gender | - |----------| - | F | - | M | - +----------+ + +--------+ + | gender | + |--------| + | F | + | M | + +--------+ Example 2: Find the least common values organized by gender @@ -49,14 +49,14 @@ PPL query:: os> source=accounts | rare age by gender; fetched rows / total rows = 4/4 - +----------+-------+ - | gender | age | - |----------+-------| - | F | 28 | - | M | 32 | - | M | 33 | - | M | 36 | - +----------+-------+ + +--------+-----+ + | gender | age | + |--------+-----| + | F | 28 | + | M | 32 | + | M | 33 | + | M | 36 | + +--------+-----+ Limitation ========== diff --git a/docs/user/ppl/cmd/rename.rst b/docs/user/ppl/cmd/rename.rst index a4383a9f5f..c942884248 100644 --- a/docs/user/ppl/cmd/rename.rst +++ b/docs/user/ppl/cmd/rename.rst @@ -31,14 +31,14 @@ PPL query:: os> source=accounts | rename account_number as an | fields an; fetched rows / total rows = 4/4 - +------+ - | an | - |------| - | 1 | - | 6 | - | 13 | - | 18 | - +------+ + +----+ + | an | + |----| + | 1 | + | 6 | + | 13 | + | 18 | + +----+ Example 2: Rename multiple fields @@ -50,14 +50,14 @@ PPL query:: os> source=accounts | rename account_number as an, employer as emp | fields an, emp; fetched rows / total rows = 4/4 - +------+---------+ - | an | emp | - |------+---------| - | 1 | Pyrami | - | 6 | Netagy | - | 13 | Quility | - | 18 | null | - +------+---------+ + +----+---------+ + | an | emp | + |----+---------| + | 1 | Pyrami | + | 6 | Netagy | + | 13 | Quility | + | 18 | null | + +----+---------+ Limitation ========== diff --git a/docs/user/ppl/cmd/search.rst b/docs/user/ppl/cmd/search.rst index 5299f9f78a..9e55daddeb 100644 --- a/docs/user/ppl/cmd/search.rst +++ b/docs/user/ppl/cmd/search.rst @@ -37,14 +37,14 @@ PPL query:: os> source=accounts; fetched rows / total rows = 4/4 - +------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+ - | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | - |------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------| - | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | - | 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond | - | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | - | 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams | - +------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+ + +----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------+ + | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | + |----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------| + | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | + | 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond | + | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | + | 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams | + +----------------+-----------+----------------------+---------+--------+--------+----------+-------+-----+-----------------------+----------+ Example 2: Fetch data with condition ==================================== @@ -55,10 +55,10 @@ PPL query:: os> source=accounts account_number=1 or gender="F"; fetched rows / total rows = 2/2 - +------------------+-------------+--------------------+-----------+----------+--------+------------+---------+-------+----------------------+------------+ - | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | - |------------------+-------------+--------------------+-----------+----------+--------+------------+---------+-------+----------------------+------------| - | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | - | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | - +------------------+-------------+--------------------+-----------+----------+--------+------------+---------+-------+----------------------+------------+ + +----------------+-----------+--------------------+---------+--------+--------+----------+-------+-----+----------------------+----------+ + | account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname | + |----------------+-----------+--------------------+---------+--------+--------+----------+-------+-----+----------------------+----------| + | 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke | + | 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates | + +----------------+-----------+--------------------+---------+--------+--------+----------+-------+-----+----------------------+----------+ diff --git a/docs/user/ppl/cmd/showdatasources.rst b/docs/user/ppl/cmd/showdatasources.rst index f7c6beb82f..d954ef0c04 100644 --- a/docs/user/ppl/cmd/showdatasources.rst +++ b/docs/user/ppl/cmd/showdatasources.rst @@ -28,9 +28,9 @@ PPL query for all PROMETHEUS DATASOURCES:: os> show datasources | where CONNECTOR_TYPE='PROMETHEUS'; fetched rows / total rows = 1/1 - +-------------------+------------------+ - | DATASOURCE_NAME | CONNECTOR_TYPE | - |-------------------+------------------| - | my_prometheus | PROMETHEUS | - +-------------------+------------------+ + +-----------------+----------------+ + | DATASOURCE_NAME | CONNECTOR_TYPE | + |-----------------+----------------| + | my_prometheus | PROMETHEUS | + +-----------------+----------------+ diff --git a/docs/user/ppl/cmd/sort.rst b/docs/user/ppl/cmd/sort.rst index 6a00ebc24c..377f0a5e01 100644 --- a/docs/user/ppl/cmd/sort.rst +++ b/docs/user/ppl/cmd/sort.rst @@ -32,14 +32,14 @@ PPL query:: os> source=accounts | sort age | fields account_number, age; fetched rows / total rows = 4/4 - +------------------+-------+ - | account_number | age | - |------------------+-------| - | 13 | 28 | - | 1 | 32 | - | 18 | 33 | - | 6 | 36 | - +------------------+-------+ + +----------------+-----+ + | account_number | age | + |----------------+-----| + | 13 | 28 | + | 1 | 32 | + | 18 | 33 | + | 6 | 36 | + +----------------+-----+ Example 2: Sort by one field return all the result @@ -51,14 +51,14 @@ PPL query:: os> source=accounts | sort age | fields account_number, age; fetched rows / total rows = 4/4 - +------------------+-------+ - | account_number | age | - |------------------+-------| - | 13 | 28 | - | 1 | 32 | - | 18 | 33 | - | 6 | 36 | - +------------------+-------+ + +----------------+-----+ + | account_number | age | + |----------------+-----| + | 13 | 28 | + | 1 | 32 | + | 18 | 33 | + | 6 | 36 | + +----------------+-----+ Example 3: Sort by one field in descending order @@ -70,14 +70,14 @@ PPL query:: os> source=accounts | sort - age | fields account_number, age; fetched rows / total rows = 4/4 - +------------------+-------+ - | account_number | age | - |------------------+-------| - | 6 | 36 | - | 18 | 33 | - | 1 | 32 | - | 13 | 28 | - +------------------+-------+ + +----------------+-----+ + | account_number | age | + |----------------+-----| + | 6 | 36 | + | 18 | 33 | + | 1 | 32 | + | 13 | 28 | + +----------------+-----+ Example 4: Sort by multiple field ============================= @@ -88,14 +88,14 @@ PPL query:: os> source=accounts | sort + gender, - age | fields account_number, gender, age; fetched rows / total rows = 4/4 - +------------------+----------+-------+ - | account_number | gender | age | - |------------------+----------+-------| - | 13 | F | 28 | - | 6 | M | 36 | - | 18 | M | 33 | - | 1 | M | 32 | - +------------------+----------+-------+ + +----------------+--------+-----+ + | account_number | gender | age | + |----------------+--------+-----| + | 13 | F | 28 | + | 6 | M | 36 | + | 18 | M | 33 | + | 1 | M | 32 | + +----------------+--------+-----+ Example 4: Sort by field include null value =========================================== @@ -106,11 +106,11 @@ PPL query:: os> source=accounts | sort employer | fields employer; fetched rows / total rows = 4/4 - +------------+ - | employer | - |------------| - | null | - | Netagy | - | Pyrami | - | Quility | - +------------+ + +----------+ + | employer | + |----------| + | null | + | Netagy | + | Pyrami | + | Quility | + +----------+ diff --git a/docs/user/ppl/cmd/stats.rst b/docs/user/ppl/cmd/stats.rst index 19f5069bba..7d5da804ce 100644 --- a/docs/user/ppl/cmd/stats.rst +++ b/docs/user/ppl/cmd/stats.rst @@ -86,11 +86,11 @@ Example:: os> source=accounts | stats count(); fetched rows / total rows = 1/1 - +-----------+ - | count() | - |-----------| - | 4 | - +-----------+ + +---------+ + | count() | + |---------| + | 4 | + +---------+ SUM --- @@ -104,12 +104,12 @@ Example:: os> source=accounts | stats sum(age) by gender; fetched rows / total rows = 2/2 - +------------+----------+ - | sum(age) | gender | - |------------+----------| - | 28 | F | - | 101 | M | - +------------+----------+ + +----------+--------+ + | sum(age) | gender | + |----------+--------| + | 28 | F | + | 101 | M | + +----------+--------+ AVG --- @@ -123,12 +123,12 @@ Example:: os> source=accounts | stats avg(age) by gender; fetched rows / total rows = 2/2 - +--------------------+----------+ - | avg(age) | gender | - |--------------------+----------| - | 28.0 | F | - | 33.666666666666664 | M | - +--------------------+----------+ + +--------------------+--------+ + | avg(age) | gender | + |--------------------+--------| + | 28.0 | F | + | 33.666666666666664 | M | + +--------------------+--------+ MAX --- @@ -142,11 +142,11 @@ Example:: os> source=accounts | stats max(age); fetched rows / total rows = 1/1 - +------------+ - | max(age) | - |------------| - | 36 | - +------------+ + +----------+ + | max(age) | + |----------| + | 36 | + +----------+ MIN --- @@ -160,11 +160,11 @@ Example:: os> source=accounts | stats min(age); fetched rows / total rows = 1/1 - +------------+ - | min(age) | - |------------| - | 28 | - +------------+ + +----------+ + | min(age) | + |----------| + | 28 | + +----------+ VAR_SAMP -------- @@ -196,11 +196,11 @@ Example:: os> source=accounts | stats var_pop(age); fetched rows / total rows = 1/1 - +----------------+ - | var_pop(age) | - |----------------| - | 8.1875 | - +----------------+ + +--------------+ + | var_pop(age) | + |--------------| + | 8.1875 | + +--------------+ STDDEV_SAMP ----------- @@ -214,11 +214,11 @@ Example:: os> source=accounts | stats stddev_samp(age); fetched rows / total rows = 1/1 - +--------------------+ - | stddev_samp(age) | - |--------------------| - | 3.304037933599835 | - +--------------------+ + +-------------------+ + | stddev_samp(age) | + |-------------------| + | 3.304037933599835 | + +-------------------+ STDDEV_POP ---------- @@ -273,12 +273,12 @@ Example:: os> source=accounts | stats percentile(age, 90) by gender; fetched rows / total rows = 2/2 - +-----------------------+----------+ - | percentile(age, 90) | gender | - |-----------------------+----------| - | 28 | F | - | 36 | M | - +-----------------------+----------+ + +---------------------+--------+ + | percentile(age, 90) | gender | + |---------------------+--------| + | 28 | F | + | 36 | M | + +---------------------+--------+ Example 1: Calculate the count of events ======================================== @@ -289,11 +289,11 @@ PPL query:: os> source=accounts | stats count(); fetched rows / total rows = 1/1 - +-----------+ - | count() | - |-----------| - | 4 | - +-----------+ + +---------+ + | count() | + |---------| + | 4 | + +---------+ Example 2: Calculate the average of a field @@ -305,11 +305,11 @@ PPL query:: os> source=accounts | stats avg(age); fetched rows / total rows = 1/1 - +------------+ - | avg(age) | - |------------| - | 32.25 | - +------------+ + +----------+ + | avg(age) | + |----------| + | 32.25 | + +----------+ Example 3: Calculate the average of a field by group @@ -321,12 +321,12 @@ PPL query:: os> source=accounts | stats avg(age) by gender; fetched rows / total rows = 2/2 - +--------------------+----------+ - | avg(age) | gender | - |--------------------+----------| - | 28.0 | F | - | 33.666666666666664 | M | - +--------------------+----------+ + +--------------------+--------+ + | avg(age) | gender | + |--------------------+--------| + | 28.0 | F | + | 33.666666666666664 | M | + +--------------------+--------+ Example 4: Calculate the average, sum and count of a field by group @@ -338,12 +338,12 @@ PPL query:: os> source=accounts | stats avg(age), sum(age), count() by gender; fetched rows / total rows = 2/2 - +--------------------+------------+-----------+----------+ - | avg(age) | sum(age) | count() | gender | - |--------------------+------------+-----------+----------| - | 28.0 | 28 | 1 | F | - | 33.666666666666664 | 101 | 3 | M | - +--------------------+------------+-----------+----------+ + +--------------------+----------+---------+--------+ + | avg(age) | sum(age) | count() | gender | + |--------------------+----------+---------+--------| + | 28.0 | 28 | 1 | F | + | 33.666666666666664 | 101 | 3 | M | + +--------------------+----------+---------+--------+ Example 5: Calculate the maximum of a field =========================================== @@ -354,11 +354,11 @@ PPL query:: os> source=accounts | stats max(age); fetched rows / total rows = 1/1 - +------------+ - | max(age) | - |------------| - | 36 | - +------------+ + +----------+ + | max(age) | + |----------| + | 36 | + +----------+ Example 6: Calculate the maximum and minimum of a field by group ================================================================ @@ -369,12 +369,12 @@ PPL query:: os> source=accounts | stats max(age), min(age) by gender; fetched rows / total rows = 2/2 - +------------+------------+----------+ - | max(age) | min(age) | gender | - |------------+------------+----------| - | 28 | 28 | F | - | 36 | 32 | M | - +------------+------------+----------+ + +----------+----------+--------+ + | max(age) | min(age) | gender | + |----------+----------+--------| + | 28 | 28 | F | + | 36 | 32 | M | + +----------+----------+--------+ Example 7: Calculate the distinct count of a field ================================================== @@ -385,11 +385,11 @@ PPL query:: os> source=accounts | stats count(gender), distinct_count(gender); fetched rows / total rows = 1/1 - +-----------------+--------------------------+ - | count(gender) | distinct_count(gender) | - |-----------------+--------------------------| - | 4 | 2 | - +-----------------+--------------------------+ + +---------------+------------------------+ + | count(gender) | distinct_count(gender) | + |---------------+------------------------| + | 4 | 2 | + +---------------+------------------------+ Example 8: Calculate the count by a span ======================================== @@ -400,12 +400,12 @@ PPL query:: os> source=accounts | stats count(age) by span(age, 10) as age_span fetched rows / total rows = 2/2 - +--------------+------------+ - | count(age) | age_span | - |--------------+------------| - | 1 | 20 | - | 3 | 30 | - +--------------+------------+ + +------------+----------+ + | count(age) | age_span | + |------------+----------| + | 1 | 20 | + | 3 | 30 | + +------------+----------+ Example 9: Calculate the count by a gender and span =================================================== @@ -416,13 +416,13 @@ PPL query:: os> source=accounts | stats count() as cnt by span(age, 5) as age_span, gender fetched rows / total rows = 3/3 - +-------+------------+----------+ - | cnt | age_span | gender | - |-------+------------+----------| - | 1 | 25 | F | - | 2 | 30 | M | - | 1 | 35 | M | - +-------+------------+----------+ + +-----+----------+--------+ + | cnt | age_span | gender | + |-----+----------+--------| + | 1 | 25 | F | + | 2 | 30 | M | + | 1 | 35 | M | + +-----+----------+--------+ Span will always be the first grouping key whatever order you specify. @@ -430,13 +430,13 @@ PPL query:: os> source=accounts | stats count() as cnt by gender, span(age, 5) as age_span fetched rows / total rows = 3/3 - +-------+------------+----------+ - | cnt | age_span | gender | - |-------+------------+----------| - | 1 | 25 | F | - | 2 | 30 | M | - | 1 | 35 | M | - +-------+------------+----------+ + +-----+----------+--------+ + | cnt | age_span | gender | + |-----+----------+--------| + | 1 | 25 | F | + | 2 | 30 | M | + | 1 | 35 | M | + +-----+----------+--------+ Example 10: Calculate the count and get email list by a gender and span ======================================================================= @@ -447,13 +447,13 @@ PPL query:: os> source=accounts | stats count() as cnt, take(email, 5) by span(age, 5) as age_span, gender fetched rows / total rows = 3/3 - +-------+--------------------------------------------+------------+----------+ - | cnt | take(email, 5) | age_span | gender | - |-------+--------------------------------------------+------------+----------| - | 1 | [] | 25 | F | - | 2 | [amberduke@pyrami.com,daleadams@boink.com] | 30 | M | - | 1 | [hattiebond@netagy.com] | 35 | M | - +-------+--------------------------------------------+------------+----------+ + +-----+--------------------------------------------+----------+--------+ + | cnt | take(email, 5) | age_span | gender | + |-----+--------------------------------------------+----------+--------| + | 1 | [] | 25 | F | + | 2 | [amberduke@pyrami.com,daleadams@boink.com] | 30 | M | + | 1 | [hattiebond@netagy.com] | 35 | M | + +-----+--------------------------------------------+----------+--------+ Example 11: Calculate the percentile of a field =============================================== @@ -464,11 +464,11 @@ PPL query:: os> source=accounts | stats percentile(age, 90); fetched rows / total rows = 1/1 - +-----------------------+ - | percentile(age, 90) | - |-----------------------| - | 36 | - +-----------------------+ + +---------------------+ + | percentile(age, 90) | + |---------------------| + | 36 | + +---------------------+ Example 12: Calculate the percentile of a field by group @@ -480,12 +480,12 @@ PPL query:: os> source=accounts | stats percentile(age, 90) by gender; fetched rows / total rows = 2/2 - +-----------------------+----------+ - | percentile(age, 90) | gender | - |-----------------------+----------| - | 28 | F | - | 36 | M | - +-----------------------+----------+ + +---------------------+--------+ + | percentile(age, 90) | gender | + |---------------------+--------| + | 28 | F | + | 36 | M | + +---------------------+--------+ Example 13: Calculate the percentile by a gender and span ========================================================= @@ -496,10 +496,10 @@ PPL query:: os> source=accounts | stats percentile(age, 90) as p90 by span(age, 10) as age_span, gender fetched rows / total rows = 2/2 - +-------+------------+----------+ - | p90 | age_span | gender | - |-------+------------+----------| - | 28 | 20 | F | - | 36 | 30 | M | - +-------+------------+----------+ + +-----+----------+--------+ + | p90 | age_span | gender | + |-----+----------+--------| + | 28 | 20 | F | + | 36 | 30 | M | + +-----+----------+--------+ diff --git a/docs/user/ppl/cmd/top.rst b/docs/user/ppl/cmd/top.rst index cbab675d09..6fa4d9cdb0 100644 --- a/docs/user/ppl/cmd/top.rst +++ b/docs/user/ppl/cmd/top.rst @@ -32,12 +32,12 @@ PPL query:: os> source=accounts | top gender; fetched rows / total rows = 2/2 - +----------+ - | gender | - |----------| - | M | - | F | - +----------+ + +--------+ + | gender | + |--------| + | M | + | F | + +--------+ Example 2: Find the most common values in a field =========================================== @@ -48,11 +48,11 @@ PPL query:: os> source=accounts | top 1 gender; fetched rows / total rows = 1/1 - +----------+ - | gender | - |----------| - | M | - +----------+ + +--------+ + | gender | + |--------| + | M | + +--------+ Example 2: Find the most common values organized by gender ==================================================== @@ -63,12 +63,12 @@ PPL query:: os> source=accounts | top 1 age by gender; fetched rows / total rows = 2/2 - +----------+-------+ - | gender | age | - |----------+-------| - | F | 28 | - | M | 32 | - +----------+-------+ + +--------+-----+ + | gender | age | + |--------+-----| + | F | 28 | + | M | 32 | + +--------+-----+ Limitation ========== diff --git a/docs/user/ppl/cmd/where.rst b/docs/user/ppl/cmd/where.rst index 4d8718d69f..115bffe7de 100644 --- a/docs/user/ppl/cmd/where.rst +++ b/docs/user/ppl/cmd/where.rst @@ -29,10 +29,10 @@ PPL query:: os> source=accounts | where account_number=1 or gender="F" | fields account_number, gender; fetched rows / total rows = 2/2 - +------------------+----------+ - | account_number | gender | - |------------------+----------| - | 1 | M | - | 13 | F | - +------------------+----------+ + +----------------+--------+ + | account_number | gender | + |----------------+--------| + | 1 | M | + | 13 | F | + +----------------+--------+ diff --git a/docs/user/ppl/functions/condition.rst b/docs/user/ppl/functions/condition.rst index e48d4cb75c..96c3e64e72 100644 --- a/docs/user/ppl/functions/condition.rst +++ b/docs/user/ppl/functions/condition.rst @@ -24,14 +24,14 @@ Example:: os> source=accounts | eval result = isnull(employer) | fields result, employer, firstname fetched rows / total rows = 4/4 - +----------+------------+-------------+ - | result | employer | firstname | - |----------+------------+-------------| - | False | Pyrami | Amber | - | False | Netagy | Hattie | - | False | Quility | Nanette | - | True | null | Dale | - +----------+------------+-------------+ + +--------+----------+-----------+ + | result | employer | firstname | + |--------+----------+-----------| + | False | Pyrami | Amber | + | False | Netagy | Hattie | + | False | Quility | Nanette | + | True | null | Dale | + +--------+----------+-----------+ ISNOTNULL --------- @@ -49,11 +49,11 @@ Example:: os> source=accounts | where not isnotnull(employer) | fields account_number, employer fetched rows / total rows = 1/1 - +------------------+------------+ - | account_number | employer | - |------------------+------------| - | 18 | null | - +------------------+------------+ + +----------------+----------+ + | account_number | employer | + |----------------+----------| + | 18 | null | + +----------------+----------+ EXISTS ------ @@ -64,11 +64,11 @@ Example, the account 13 doesn't have email field:: os> source=accounts | where isnull(email) | fields account_number, email fetched rows / total rows = 1/1 - +------------------+---------+ - | account_number | email | - |------------------+---------| - | 13 | null | - +------------------+---------+ + +----------------+-------+ + | account_number | email | + |----------------+-------| + | 13 | null | + +----------------+-------+ IFNULL ------ @@ -86,14 +86,14 @@ Example:: os> source=accounts | eval result = ifnull(employer, 'default') | fields result, employer, firstname fetched rows / total rows = 4/4 - +----------+------------+-------------+ - | result | employer | firstname | - |----------+------------+-------------| - | Pyrami | Pyrami | Amber | - | Netagy | Netagy | Hattie | - | Quility | Quility | Nanette | - | default | null | Dale | - +----------+------------+-------------+ + +---------+----------+-----------+ + | result | employer | firstname | + |---------+----------+-----------| + | Pyrami | Pyrami | Amber | + | Netagy | Netagy | Hattie | + | Quility | Quility | Nanette | + | default | null | Dale | + +---------+----------+-----------+ NULLIF ------ @@ -111,14 +111,14 @@ Example:: os> source=accounts | eval result = nullif(employer, 'Pyrami') | fields result, employer, firstname fetched rows / total rows = 4/4 - +----------+------------+-------------+ - | result | employer | firstname | - |----------+------------+-------------| - | null | Pyrami | Amber | - | Netagy | Netagy | Hattie | - | Quility | Quility | Nanette | - | null | null | Dale | - +----------+------------+-------------+ + +---------+----------+-----------+ + | result | employer | firstname | + |---------+----------+-----------| + | null | Pyrami | Amber | + | Netagy | Netagy | Hattie | + | Quility | Quility | Nanette | + | null | null | Dale | + +---------+----------+-----------+ ISNULL @@ -137,14 +137,14 @@ Example:: os> source=accounts | eval result = isnull(employer) | fields result, employer, firstname fetched rows / total rows = 4/4 - +----------+------------+-------------+ - | result | employer | firstname | - |----------+------------+-------------| - | False | Pyrami | Amber | - | False | Netagy | Hattie | - | False | Quility | Nanette | - | True | null | Dale | - +----------+------------+-------------+ + +--------+----------+-----------+ + | result | employer | firstname | + |--------+----------+-----------| + | False | Pyrami | Amber | + | False | Netagy | Hattie | + | False | Quility | Nanette | + | True | null | Dale | + +--------+----------+-----------+ IF ------ @@ -162,33 +162,33 @@ Example:: os> source=accounts | eval result = if(true, firstname, lastname) | fields result, firstname, lastname fetched rows / total rows = 4/4 - +----------+-------------+------------+ - | result | firstname | lastname | - |----------+-------------+------------| - | Amber | Amber | Duke | - | Hattie | Hattie | Bond | - | Nanette | Nanette | Bates | - | Dale | Dale | Adams | - +----------+-------------+------------+ + +---------+-----------+----------+ + | result | firstname | lastname | + |---------+-----------+----------| + | Amber | Amber | Duke | + | Hattie | Hattie | Bond | + | Nanette | Nanette | Bates | + | Dale | Dale | Adams | + +---------+-----------+----------+ os> source=accounts | eval result = if(false, firstname, lastname) | fields result, firstname, lastname fetched rows / total rows = 4/4 - +----------+-------------+------------+ - | result | firstname | lastname | - |----------+-------------+------------| - | Duke | Amber | Duke | - | Bond | Hattie | Bond | - | Bates | Nanette | Bates | - | Adams | Dale | Adams | - +----------+-------------+------------+ + +--------+-----------+----------+ + | result | firstname | lastname | + |--------+-----------+----------| + | Duke | Amber | Duke | + | Bond | Hattie | Bond | + | Bates | Nanette | Bates | + | Adams | Dale | Adams | + +--------+-----------+----------+ os> source=accounts | eval is_vip = if(age > 30 AND isnotnull(employer), true, false) | fields is_vip, firstname, lastname fetched rows / total rows = 4/4 - +----------+-------------+------------+ - | is_vip | firstname | lastname | - |----------+-------------+------------| - | True | Amber | Duke | - | True | Hattie | Bond | - | False | Nanette | Bates | - | False | Dale | Adams | - +----------+-------------+------------+ + +--------+-----------+----------+ + | is_vip | firstname | lastname | + |--------+-----------+----------| + | True | Amber | Duke | + | True | Hattie | Bond | + | False | Nanette | Bates | + | False | Dale | Adams | + +--------+-----------+----------+ diff --git a/docs/user/ppl/functions/conversion.rst b/docs/user/ppl/functions/conversion.rst index a4a59a6cd1..31fb3e3cdf 100644 --- a/docs/user/ppl/functions/conversion.rst +++ b/docs/user/ppl/functions/conversion.rst @@ -38,21 +38,21 @@ Cast to string example:: os> source=people | eval `cbool` = CAST(true as string), `cint` = CAST(1 as string), `cdate` = CAST(CAST('2012-08-07' as date) as string) | fields `cbool`, `cint`, `cdate` fetched rows / total rows = 1/1 - +---------+--------+------------+ - | cbool | cint | cdate | - |---------+--------+------------| - | true | 1 | 2012-08-07 | - +---------+--------+------------+ + +-------+------+------------+ + | cbool | cint | cdate | + |-------+------+------------| + | true | 1 | 2012-08-07 | + +-------+------+------------+ Cast to number example:: os> source=people | eval `cbool` = CAST(true as int), `cstring` = CAST('1' as int) | fields `cbool`, `cstring` fetched rows / total rows = 1/1 - +---------+-----------+ - | cbool | cstring | - |---------+-----------| - | 1 | 1 | - +---------+-----------+ + +-------+---------+ + | cbool | cstring | + |-------+---------| + | 1 | 1 | + +-------+---------+ Cast to date example:: @@ -68,8 +68,8 @@ Cast function can be chained:: os> source=people | eval `cbool` = CAST(CAST(true as string) as boolean) | fields `cbool` fetched rows / total rows = 1/1 - +---------+ - | cbool | - |---------| - | True | - +---------+ + +-------+ + | cbool | + |-------| + | True | + +-------+ diff --git a/docs/user/ppl/functions/datetime.rst b/docs/user/ppl/functions/datetime.rst index 9e75e41136..c0d42297ac 100644 --- a/docs/user/ppl/functions/datetime.rst +++ b/docs/user/ppl/functions/datetime.rst @@ -35,11 +35,11 @@ Example:: os> source=people | eval `'2020-08-26' + 1h` = ADDDATE(DATE('2020-08-26'), INTERVAL 1 HOUR), `'2020-08-26' + 1` = ADDDATE(DATE('2020-08-26'), 1), `ts '2020-08-26 01:01:01' + 1` = ADDDATE(TIMESTAMP('2020-08-26 01:01:01'), 1) | fields `'2020-08-26' + 1h`, `'2020-08-26' + 1`, `ts '2020-08-26 01:01:01' + 1` fetched rows / total rows = 1/1 - +---------------------+--------------------+--------------------------------+ - | '2020-08-26' + 1h | '2020-08-26' + 1 | ts '2020-08-26 01:01:01' + 1 | - |---------------------+--------------------+--------------------------------| - | 2020-08-26 01:00:00 | 2020-08-27 | 2020-08-27 01:01:01 | - +---------------------+--------------------+--------------------------------+ + +---------------------+------------------+------------------------------+ + | '2020-08-26' + 1h | '2020-08-26' + 1 | ts '2020-08-26 01:01:01' + 1 | + |---------------------+------------------+------------------------------| + | 2020-08-26 01:00:00 | 2020-08-27 | 2020-08-27 01:01:01 | + +---------------------+------------------+------------------------------+ @@ -73,35 +73,35 @@ Example:: os> source=people | eval `'23:59:59' + 0` = ADDTIME(TIME('23:59:59'), DATE('2004-01-01')) | fields `'23:59:59' + 0` fetched rows / total rows = 1/1 - +------------------+ - | '23:59:59' + 0 | - |------------------| - | 23:59:59 | - +------------------+ + +----------------+ + | '23:59:59' + 0 | + |----------------| + | 23:59:59 | + +----------------+ os> source=people | eval `'2004-01-01' + '23:59:59'` = ADDTIME(DATE('2004-01-01'), TIME('23:59:59')) | fields `'2004-01-01' + '23:59:59'` fetched rows / total rows = 1/1 - +-----------------------------+ - | '2004-01-01' + '23:59:59' | - |-----------------------------| - | 2004-01-01 23:59:59 | - +-----------------------------+ - - os> source=people | eval `'10:20:30' + '00:05:42'` = ADDTIME(TIME('10:20:30'), TIME('00:05:42')) | fields `'10:20:30' + '00:05:42'` - fetched rows / total rows = 1/1 +---------------------------+ - | '10:20:30' + '00:05:42' | + | '2004-01-01' + '23:59:59' | |---------------------------| - | 10:26:12 | + | 2004-01-01 23:59:59 | +---------------------------+ + os> source=people | eval `'10:20:30' + '00:05:42'` = ADDTIME(TIME('10:20:30'), TIME('00:05:42')) | fields `'10:20:30' + '00:05:42'` + fetched rows / total rows = 1/1 + +-------------------------+ + | '10:20:30' + '00:05:42' | + |-------------------------| + | 10:26:12 | + +-------------------------+ + os> source=people | eval `'2007-02-28 10:20:30' + '20:40:50'` = ADDTIME(TIMESTAMP('2007-02-28 10:20:30'), TIMESTAMP('2002-03-04 20:40:50')) | fields `'2007-02-28 10:20:30' + '20:40:50'` fetched rows / total rows = 1/1 - +--------------------------------------+ - | '2007-02-28 10:20:30' + '20:40:50' | - |--------------------------------------| - | 2007-03-01 07:01:20 | - +--------------------------------------+ + +------------------------------------+ + | '2007-02-28 10:20:30' + '20:40:50' | + |------------------------------------| + | 2007-03-01 07:01:20 | + +------------------------------------+ CONVERT_TZ @@ -121,121 +121,121 @@ Example:: os> source=people | eval `convert_tz('2008-05-15 12:00:00','+00:00','+10:00')` = convert_tz('2008-05-15 12:00:00','+00:00','+10:00') | fields `convert_tz('2008-05-15 12:00:00','+00:00','+10:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-05-15 12:00:00','+00:00','+10:00') | - |-------------------------------------------------------| - | 2008-05-15 22:00:00 | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-05-15 12:00:00','+00:00','+10:00') | + |-----------------------------------------------------| + | 2008-05-15 22:00:00 | + +-----------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. Timezones outside of the range, such as +15:00 in this example will return null. Example:: os> source=people | eval `convert_tz('2008-05-15 12:00:00','+00:00','+15:00')` = convert_tz('2008-05-15 12:00:00','+00:00','+15:00')| fields `convert_tz('2008-05-15 12:00:00','+00:00','+15:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-05-15 12:00:00','+00:00','+15:00') | - |-------------------------------------------------------| - | null | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-05-15 12:00:00','+00:00','+15:00') | + |-----------------------------------------------------| + | null | + +-----------------------------------------------------+ Conversion from a positive timezone to a negative timezone that goes over date line. Example:: os> source=people | eval `convert_tz('2008-05-15 12:00:00','+03:30','-10:00')` = convert_tz('2008-05-15 12:00:00','+03:30','-10:00') | fields `convert_tz('2008-05-15 12:00:00','+03:30','-10:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-05-15 12:00:00','+03:30','-10:00') | - |-------------------------------------------------------| - | 2008-05-14 22:30:00 | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-05-15 12:00:00','+03:30','-10:00') | + |-----------------------------------------------------| + | 2008-05-14 22:30:00 | + +-----------------------------------------------------+ Valid dates are required in convert_tz, invalid dates such as April 31st (not a date in the Gregorian calendar) will result in null. Example:: os> source=people | eval `convert_tz('2008-04-31 12:00:00','+03:30','-10:00')` = convert_tz('2008-04-31 12:00:00','+03:30','-10:00') | fields `convert_tz('2008-04-31 12:00:00','+03:30','-10:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-04-31 12:00:00','+03:30','-10:00') | - |-------------------------------------------------------| - | null | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-04-31 12:00:00','+03:30','-10:00') | + |-----------------------------------------------------| + | null | + +-----------------------------------------------------+ Valid dates are required in convert_tz, invalid dates such as February 30th (not a date in the Gregorian calendar) will result in null. Example:: os> source=people | eval `convert_tz('2008-02-30 12:00:00','+03:30','-10:00')` = convert_tz('2008-02-30 12:00:00','+03:30','-10:00') | fields `convert_tz('2008-02-30 12:00:00','+03:30','-10:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-02-30 12:00:00','+03:30','-10:00') | - |-------------------------------------------------------| - | null | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-02-30 12:00:00','+03:30','-10:00') | + |-----------------------------------------------------| + | null | + +-----------------------------------------------------+ February 29th 2008 is a valid date because it is a leap year. Example:: os> source=people | eval `convert_tz('2008-02-29 12:00:00','+03:30','-10:00')` = convert_tz('2008-02-29 12:00:00','+03:30','-10:00') | fields `convert_tz('2008-02-29 12:00:00','+03:30','-10:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-02-29 12:00:00','+03:30','-10:00') | - |-------------------------------------------------------| - | 2008-02-28 22:30:00 | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-02-29 12:00:00','+03:30','-10:00') | + |-----------------------------------------------------| + | 2008-02-28 22:30:00 | + +-----------------------------------------------------+ Valid dates are required in convert_tz, invalid dates such as February 29th 2007 (2007 is not a leap year) will result in null. Example:: os> source=people | eval `convert_tz('2007-02-29 12:00:00','+03:30','-10:00')` = convert_tz('2007-02-29 12:00:00','+03:30','-10:00') | fields `convert_tz('2007-02-29 12:00:00','+03:30','-10:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2007-02-29 12:00:00','+03:30','-10:00') | - |-------------------------------------------------------| - | null | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2007-02-29 12:00:00','+03:30','-10:00') | + |-----------------------------------------------------| + | null | + +-----------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. Timezones outside of the range, such as +14:01 in this example will return null. Example:: os> source=people | eval `convert_tz('2008-02-01 12:00:00','+14:01','+00:00')` = convert_tz('2008-02-01 12:00:00','+14:01','+00:00') | fields `convert_tz('2008-02-01 12:00:00','+14:01','+00:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-02-01 12:00:00','+14:01','+00:00') | - |-------------------------------------------------------| - | null | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-02-01 12:00:00','+14:01','+00:00') | + |-----------------------------------------------------| + | null | + +-----------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. Timezones outside of the range, such as +14:00 in this example will return a correctly converted date time object. Example:: os> source=people | eval `convert_tz('2008-02-01 12:00:00','+14:00','+00:00')` = convert_tz('2008-02-01 12:00:00','+14:00','+00:00') | fields `convert_tz('2008-02-01 12:00:00','+14:00','+00:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-02-01 12:00:00','+14:00','+00:00') | - |-------------------------------------------------------| - | 2008-01-31 22:00:00 | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-02-01 12:00:00','+14:00','+00:00') | + |-----------------------------------------------------| + | 2008-01-31 22:00:00 | + +-----------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. Timezones outside of the range, such as -14:00 will result in null Example:: os> source=people | eval `convert_tz('2008-02-01 12:00:00','-14:00','+00:00')` = convert_tz('2008-02-01 12:00:00','-14:00','+00:00') | fields `convert_tz('2008-02-01 12:00:00','-14:00','+00:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-02-01 12:00:00','-14:00','+00:00') | - |-------------------------------------------------------| - | null | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-02-01 12:00:00','-14:00','+00:00') | + |-----------------------------------------------------| + | null | + +-----------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. This timezone is within range so it is valid and will convert the time. Example:: os> source=people | eval `convert_tz('2008-02-01 12:00:00','-13:59','+00:00')` = convert_tz('2008-02-01 12:00:00','-13:59','+00:00') | fields `convert_tz('2008-02-01 12:00:00','-13:59','+00:00')` fetched rows / total rows = 1/1 - +-------------------------------------------------------+ - | convert_tz('2008-02-01 12:00:00','-13:59','+00:00') | - |-------------------------------------------------------| - | 2008-02-02 01:59:00 | - +-------------------------------------------------------+ + +-----------------------------------------------------+ + | convert_tz('2008-02-01 12:00:00','-13:59','+00:00') | + |-----------------------------------------------------| + | 2008-02-02 01:59:00 | + +-----------------------------------------------------+ CURDATE @@ -255,11 +255,11 @@ Example:: > source=people | eval `CURDATE()` = CURDATE() | fields `CURDATE()` fetched rows / total rows = 1/1 - +-------------+ - | CURDATE() | - |-------------| - | 2022-08-02 | - +-------------+ + +------------+ + | CURDATE() | + |------------| + | 2022-08-02 | + +------------+ CURRENT_DATE @@ -336,11 +336,11 @@ Example:: > source=people | eval `value_1` = CURTIME(), `value_2` = CURTIME() | fields `value_1`, `value_2` fetched rows / total rows = 1/1 - +-----------+-----------+ - | value_1 | value_2 | - |-----------+-----------| - | 15:39:05 | 15:39:05 | - +-----------+-----------+ + +----------+----------+ + | value_1 | value_2 | + |----------+----------| + | 15:39:05 | 15:39:05 | + +----------+----------+ DATE @@ -359,35 +359,35 @@ Example:: os> source=people | eval `DATE('2020-08-26')` = DATE('2020-08-26') | fields `DATE('2020-08-26')` fetched rows / total rows = 1/1 - +----------------------+ - | DATE('2020-08-26') | - |----------------------| - | 2020-08-26 | - +----------------------+ + +--------------------+ + | DATE('2020-08-26') | + |--------------------| + | 2020-08-26 | + +--------------------+ os> source=people | eval `DATE(TIMESTAMP('2020-08-26 13:49:00'))` = DATE(TIMESTAMP('2020-08-26 13:49:00')) | fields `DATE(TIMESTAMP('2020-08-26 13:49:00'))` fetched rows / total rows = 1/1 - +------------------------------------------+ - | DATE(TIMESTAMP('2020-08-26 13:49:00')) | - |------------------------------------------| - | 2020-08-26 | - +------------------------------------------+ + +----------------------------------------+ + | DATE(TIMESTAMP('2020-08-26 13:49:00')) | + |----------------------------------------| + | 2020-08-26 | + +----------------------------------------+ os> source=people | eval `DATE('2020-08-26 13:49')` = DATE('2020-08-26 13:49') | fields `DATE('2020-08-26 13:49')` fetched rows / total rows = 1/1 - +----------------------------+ - | DATE('2020-08-26 13:49') | - |----------------------------| - | 2020-08-26 | - +----------------------------+ + +--------------------------+ + | DATE('2020-08-26 13:49') | + |--------------------------| + | 2020-08-26 | + +--------------------------+ os> source=people | eval `DATE('2020-08-26 13:49')` = DATE('2020-08-26 13:49') | fields `DATE('2020-08-26 13:49')` fetched rows / total rows = 1/1 - +----------------------------+ - | DATE('2020-08-26 13:49') | - |----------------------------| - | 2020-08-26 | - +----------------------------+ + +--------------------------+ + | DATE('2020-08-26 13:49') | + |--------------------------| + | 2020-08-26 | + +--------------------------+ DATE_ADD @@ -410,11 +410,11 @@ Example:: os> source=people | eval `'2020-08-26' + 1h` = DATE_ADD(DATE('2020-08-26'), INTERVAL 1 HOUR), `ts '2020-08-26 01:01:01' + 1d` = DATE_ADD(TIMESTAMP('2020-08-26 01:01:01'), INTERVAL 1 DAY) | fields `'2020-08-26' + 1h`, `ts '2020-08-26 01:01:01' + 1d` fetched rows / total rows = 1/1 - +---------------------+---------------------------------+ - | '2020-08-26' + 1h | ts '2020-08-26 01:01:01' + 1d | - |---------------------+---------------------------------| - | 2020-08-26 01:00:00 | 2020-08-27 01:01:01 | - +---------------------+---------------------------------+ + +---------------------+-------------------------------+ + | '2020-08-26' + 1h | ts '2020-08-26 01:01:01' + 1d | + |---------------------+-------------------------------| + | 2020-08-26 01:00:00 | 2020-08-27 01:01:01 | + +---------------------+-------------------------------+ DATE_FORMAT @@ -509,11 +509,11 @@ Example:: os> source=people | eval `DATE_FORMAT('1998-01-31 13:14:15.012345', '%T.%f')` = DATE_FORMAT('1998-01-31 13:14:15.012345', '%T.%f'), `DATE_FORMAT(TIMESTAMP('1998-01-31 13:14:15.012345'), '%Y-%b-%D %r')` = DATE_FORMAT(TIMESTAMP('1998-01-31 13:14:15.012345'), '%Y-%b-%D %r') | fields `DATE_FORMAT('1998-01-31 13:14:15.012345', '%T.%f')`, `DATE_FORMAT(TIMESTAMP('1998-01-31 13:14:15.012345'), '%Y-%b-%D %r')` fetched rows / total rows = 1/1 - +------------------------------------------------------+-----------------------------------------------------------------------+ - | DATE_FORMAT('1998-01-31 13:14:15.012345', '%T.%f') | DATE_FORMAT(TIMESTAMP('1998-01-31 13:14:15.012345'), '%Y-%b-%D %r') | - |------------------------------------------------------+-----------------------------------------------------------------------| - | 13:14:15.012345 | 1998-Jan-31st 01:14:15 PM | - +------------------------------------------------------+-----------------------------------------------------------------------+ + +----------------------------------------------------+---------------------------------------------------------------------+ + | DATE_FORMAT('1998-01-31 13:14:15.012345', '%T.%f') | DATE_FORMAT(TIMESTAMP('1998-01-31 13:14:15.012345'), '%Y-%b-%D %r') | + |----------------------------------------------------+---------------------------------------------------------------------| + | 13:14:15.012345 | 1998-Jan-31st 01:14:15 PM | + +----------------------------------------------------+---------------------------------------------------------------------+ DATETIME @@ -538,11 +538,11 @@ Example:: os> source=people | eval `DATETIME('2004-02-28 23:00:00-10:00', '+10:00')` = DATETIME('2004-02-28 23:00:00-10:00', '+10:00') | fields `DATETIME('2004-02-28 23:00:00-10:00', '+10:00')` fetched rows / total rows = 1/1 - +---------------------------------------------------+ - | DATETIME('2004-02-28 23:00:00-10:00', '+10:00') | - |---------------------------------------------------| - | 2004-02-29 19:00:00 | - +---------------------------------------------------+ + +-------------------------------------------------+ + | DATETIME('2004-02-28 23:00:00-10:00', '+10:00') | + |-------------------------------------------------| + | 2004-02-29 19:00:00 | + +-------------------------------------------------+ The valid timezone range for convert_tz is (-13:59, +14:00) inclusive. Timezones outside of the range will result in null. @@ -550,11 +550,11 @@ Example:: os> source=people | eval `DATETIME('2008-01-01 02:00:00', '-14:00')` = DATETIME('2008-01-01 02:00:00', '-14:00') | fields `DATETIME('2008-01-01 02:00:00', '-14:00')` fetched rows / total rows = 1/1 - +---------------------------------------------+ - | DATETIME('2008-01-01 02:00:00', '-14:00') | - |---------------------------------------------| - | null | - +---------------------------------------------+ + +-------------------------------------------+ + | DATETIME('2008-01-01 02:00:00', '-14:00') | + |-------------------------------------------| + | null | + +-------------------------------------------+ DATE_SUB @@ -577,11 +577,11 @@ Example:: os> source=people | eval `'2008-01-02' - 31d` = DATE_SUB(DATE('2008-01-02'), INTERVAL 31 DAY), `ts '2020-08-26 01:01:01' + 1h` = DATE_SUB(TIMESTAMP('2020-08-26 01:01:01'), INTERVAL 1 HOUR) | fields `'2008-01-02' - 31d`, `ts '2020-08-26 01:01:01' + 1h` fetched rows / total rows = 1/1 - +----------------------+---------------------------------+ - | '2008-01-02' - 31d | ts '2020-08-26 01:01:01' + 1h | - |----------------------+---------------------------------| - | 2007-12-02 00:00:00 | 2020-08-26 00:01:01 | - +----------------------+---------------------------------+ + +---------------------+-------------------------------+ + | '2008-01-02' - 31d | ts '2020-08-26 01:01:01' + 1h | + |---------------------+-------------------------------| + | 2007-12-02 00:00:00 | 2020-08-26 00:01:01 | + +---------------------+-------------------------------+ DATEDIFF @@ -597,11 +597,11 @@ Example:: os> source=people | eval `'2000-01-02' - '2000-01-01'` = DATEDIFF(TIMESTAMP('2000-01-02 00:00:00'), TIMESTAMP('2000-01-01 23:59:59')), `'2001-02-01' - '2004-01-01'` = DATEDIFF(DATE('2001-02-01'), TIMESTAMP('2004-01-01 00:00:00')), `today - today` = DATEDIFF(TIME('23:59:59'), TIME('00:00:00')) | fields `'2000-01-02' - '2000-01-01'`, `'2001-02-01' - '2004-01-01'`, `today - today` fetched rows / total rows = 1/1 - +-------------------------------+-------------------------------+-----------------+ - | '2000-01-02' - '2000-01-01' | '2001-02-01' - '2004-01-01' | today - today | - |-------------------------------+-------------------------------+-----------------| - | 1 | -1064 | 0 | - +-------------------------------+-------------------------------+-----------------+ + +-----------------------------+-----------------------------+---------------+ + | '2000-01-02' - '2000-01-01' | '2001-02-01' - '2004-01-01' | today - today | + |-----------------------------+-----------------------------+---------------| + | 1 | -1064 | 0 | + +-----------------------------+-----------------------------+---------------+ DAY @@ -622,11 +622,11 @@ Example:: os> source=people | eval `DAY(DATE('2020-08-26'))` = DAY(DATE('2020-08-26')) | fields `DAY(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +---------------------------+ - | DAY(DATE('2020-08-26')) | - |---------------------------| - | 26 | - +---------------------------+ + +-------------------------+ + | DAY(DATE('2020-08-26')) | + |-------------------------| + | 26 | + +-------------------------+ DAYNAME @@ -645,11 +645,11 @@ Example:: os> source=people | eval `DAYNAME(DATE('2020-08-26'))` = DAYNAME(DATE('2020-08-26')) | fields `DAYNAME(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +-------------------------------+ - | DAYNAME(DATE('2020-08-26')) | - |-------------------------------| - | Wednesday | - +-------------------------------+ + +-----------------------------+ + | DAYNAME(DATE('2020-08-26')) | + |-----------------------------| + | Wednesday | + +-----------------------------+ DAYOFMONTH @@ -670,11 +670,11 @@ Example:: os> source=people | eval `DAYOFMONTH(DATE('2020-08-26'))` = DAYOFMONTH(DATE('2020-08-26')) | fields `DAYOFMONTH(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +----------------------------------+ - | DAYOFMONTH(DATE('2020-08-26')) | - |----------------------------------| - | 26 | - +----------------------------------+ + +--------------------------------+ + | DAYOFMONTH(DATE('2020-08-26')) | + |--------------------------------| + | 26 | + +--------------------------------+ DAY_OF_MONTH @@ -695,11 +695,11 @@ Example:: os> source=people | eval `DAY_OF_MONTH(DATE('2020-08-26'))` = DAY_OF_MONTH(DATE('2020-08-26')) | fields `DAY_OF_MONTH(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +------------------------------------+ - | DAY_OF_MONTH(DATE('2020-08-26')) | - |------------------------------------| - | 26 | - +------------------------------------+ + +----------------------------------+ + | DAY_OF_MONTH(DATE('2020-08-26')) | + |----------------------------------| + | 26 | + +----------------------------------+ DAYOFWEEK @@ -720,11 +720,11 @@ Example:: os> source=people | eval `DAYOFWEEK(DATE('2020-08-26'))` = DAYOFWEEK(DATE('2020-08-26')) | fields `DAYOFWEEK(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +---------------------------------+ - | DAYOFWEEK(DATE('2020-08-26')) | - |---------------------------------| - | 4 | - +---------------------------------+ + +-------------------------------+ + | DAYOFWEEK(DATE('2020-08-26')) | + |-------------------------------| + | 4 | + +-------------------------------+ DAY_OF_WEEK @@ -745,11 +745,11 @@ Example:: os> source=people | eval `DAY_OF_WEEK(DATE('2020-08-26'))` = DAY_OF_WEEK(DATE('2020-08-26')) | fields `DAY_OF_WEEK(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +-----------------------------------+ - | DAY_OF_WEEK(DATE('2020-08-26')) | - |-----------------------------------| - | 4 | - +-----------------------------------+ + +---------------------------------+ + | DAY_OF_WEEK(DATE('2020-08-26')) | + |---------------------------------| + | 4 | + +---------------------------------+ DAYOFYEAR @@ -770,11 +770,11 @@ Example:: os> source=people | eval `DAYOFYEAR(DATE('2020-08-26'))` = DAYOFYEAR(DATE('2020-08-26')) | fields `DAYOFYEAR(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +---------------------------------+ - | DAYOFYEAR(DATE('2020-08-26')) | - |---------------------------------| - | 239 | - +---------------------------------+ + +-------------------------------+ + | DAYOFYEAR(DATE('2020-08-26')) | + |-------------------------------| + | 239 | + +-------------------------------+ DAY_OF_YEAR @@ -795,11 +795,11 @@ Example:: os> source=people | eval `DAY_OF_YEAR(DATE('2020-08-26'))` = DAY_OF_YEAR(DATE('2020-08-26')) | fields `DAY_OF_YEAR(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +-----------------------------------+ - | DAY_OF_YEAR(DATE('2020-08-26')) | - |-----------------------------------| - | 239 | - +-----------------------------------+ + +---------------------------------+ + | DAY_OF_YEAR(DATE('2020-08-26')) | + |---------------------------------| + | 239 | + +---------------------------------+ EXTRACT @@ -866,11 +866,11 @@ Example:: os> source=people | eval `extract(YEAR_MONTH FROM "2023-02-07 10:11:12")` = extract(YEAR_MONTH FROM "2023-02-07 10:11:12") | fields `extract(YEAR_MONTH FROM "2023-02-07 10:11:12")` fetched rows / total rows = 1/1 - +--------------------------------------------------+ - | extract(YEAR_MONTH FROM "2023-02-07 10:11:12") | - |--------------------------------------------------| - | 202302 | - +--------------------------------------------------+ + +------------------------------------------------+ + | extract(YEAR_MONTH FROM "2023-02-07 10:11:12") | + |------------------------------------------------| + | 202302 | + +------------------------------------------------+ FROM_DAYS @@ -889,11 +889,11 @@ Example:: os> source=people | eval `FROM_DAYS(733687)` = FROM_DAYS(733687) | fields `FROM_DAYS(733687)` fetched rows / total rows = 1/1 - +---------------------+ - | FROM_DAYS(733687) | - |---------------------| - | 2008-10-07 | - +---------------------+ + +-------------------+ + | FROM_DAYS(733687) | + |-------------------| + | 2008-10-07 | + +-------------------+ FROM_UNIXTIME @@ -917,19 +917,19 @@ Examples:: os> source=people | eval `FROM_UNIXTIME(1220249547)` = FROM_UNIXTIME(1220249547) | fields `FROM_UNIXTIME(1220249547)` fetched rows / total rows = 1/1 - +-----------------------------+ - | FROM_UNIXTIME(1220249547) | - |-----------------------------| - | 2008-09-01 06:12:27 | - +-----------------------------+ + +---------------------------+ + | FROM_UNIXTIME(1220249547) | + |---------------------------| + | 2008-09-01 06:12:27 | + +---------------------------+ os> source=people | eval `FROM_UNIXTIME(1220249547, '%T')` = FROM_UNIXTIME(1220249547, '%T') | fields `FROM_UNIXTIME(1220249547, '%T')` fetched rows / total rows = 1/1 - +-----------------------------------+ - | FROM_UNIXTIME(1220249547, '%T') | - |-----------------------------------| - | 06:12:27 | - +-----------------------------------+ + +---------------------------------+ + | FROM_UNIXTIME(1220249547, '%T') | + |---------------------------------| + | 06:12:27 | + +---------------------------------+ GET_FORMAT @@ -947,11 +947,11 @@ Examples:: os> source=people | eval `GET_FORMAT(DATE, 'USA')` = GET_FORMAT(DATE, 'USA') | fields `GET_FORMAT(DATE, 'USA')` fetched rows / total rows = 1/1 - +---------------------------+ - | GET_FORMAT(DATE, 'USA') | - |---------------------------| - | %m.%d.%Y | - +---------------------------+ + +-------------------------+ + | GET_FORMAT(DATE, 'USA') | + |-------------------------| + | %m.%d.%Y | + +-------------------------+ HOUR @@ -972,11 +972,11 @@ Example:: os> source=people | eval `HOUR(TIME('01:02:03'))` = HOUR(TIME('01:02:03')) | fields `HOUR(TIME('01:02:03'))` fetched rows / total rows = 1/1 - +--------------------------+ - | HOUR(TIME('01:02:03')) | - |--------------------------| - | 1 | - +--------------------------+ + +------------------------+ + | HOUR(TIME('01:02:03')) | + |------------------------| + | 1 | + +------------------------+ HOUR_OF_DAY @@ -997,11 +997,11 @@ Example:: os> source=people | eval `HOUR_OF_DAY(TIME('01:02:03'))` = HOUR_OF_DAY(TIME('01:02:03')) | fields `HOUR_OF_DAY(TIME('01:02:03'))` fetched rows / total rows = 1/1 - +---------------------------------+ - | HOUR_OF_DAY(TIME('01:02:03')) | - |---------------------------------| - | 1 | - +---------------------------------+ + +-------------------------------+ + | HOUR_OF_DAY(TIME('01:02:03')) | + |-------------------------------| + | 1 | + +-------------------------------+ LAST_DAY @@ -1017,11 +1017,11 @@ Example:: os> source=people | eval `last_day('2023-02-06')` = last_day('2023-02-06') | fields `last_day('2023-02-06')` fetched rows / total rows = 1/1 - +--------------------------+ - | last_day('2023-02-06') | - |--------------------------| - | 2023-02-28 | - +--------------------------+ + +------------------------+ + | last_day('2023-02-06') | + |------------------------| + | 2023-02-28 | + +------------------------+ LOCALTIMESTAMP @@ -1089,11 +1089,11 @@ Example:: os> source=people | eval `MAKEDATE(1945, 5.9)` = MAKEDATE(1945, 5.9), `MAKEDATE(1984, 1984)` = MAKEDATE(1984, 1984) | fields `MAKEDATE(1945, 5.9)`, `MAKEDATE(1984, 1984)` fetched rows / total rows = 1/1 - +-----------------------+------------------------+ - | MAKEDATE(1945, 5.9) | MAKEDATE(1984, 1984) | - |-----------------------+------------------------| - | 1945-01-06 | 1989-06-06 | - +-----------------------+------------------------+ + +---------------------+----------------------+ + | MAKEDATE(1945, 5.9) | MAKEDATE(1984, 1984) | + |---------------------+----------------------| + | 1945-01-06 | 1989-06-06 | + +---------------------+----------------------+ MAKETIME @@ -1121,11 +1121,11 @@ Example:: os> source=people | eval `MAKETIME(20, 30, 40)` = MAKETIME(20, 30, 40), `MAKETIME(20.2, 49.5, 42.100502)` = MAKETIME(20.2, 49.5, 42.100502) | fields `MAKETIME(20, 30, 40)`, `MAKETIME(20.2, 49.5, 42.100502)` fetched rows / total rows = 1/1 - +------------------------+-----------------------------------+ - | MAKETIME(20, 30, 40) | MAKETIME(20.2, 49.5, 42.100502) | - |------------------------+-----------------------------------| - | 20:30:40 | 20:50:42.100502 | - +------------------------+-----------------------------------+ + +----------------------+---------------------------------+ + | MAKETIME(20, 30, 40) | MAKETIME(20.2, 49.5, 42.100502) | + |----------------------+---------------------------------| + | 20:30:40 | 20:50:42.100502 | + +----------------------+---------------------------------+ MICROSECOND @@ -1144,11 +1144,11 @@ Example:: os> source=people | eval `MICROSECOND(TIME('01:02:03.123456'))` = MICROSECOND(TIME('01:02:03.123456')) | fields `MICROSECOND(TIME('01:02:03.123456'))` fetched rows / total rows = 1/1 - +----------------------------------------+ - | MICROSECOND(TIME('01:02:03.123456')) | - |----------------------------------------| - | 123456 | - +----------------------------------------+ + +--------------------------------------+ + | MICROSECOND(TIME('01:02:03.123456')) | + |--------------------------------------| + | 123456 | + +--------------------------------------+ MINUTE @@ -1169,11 +1169,11 @@ Example:: os> source=people | eval `MINUTE(TIME('01:02:03'))` = MINUTE(TIME('01:02:03')) | fields `MINUTE(TIME('01:02:03'))` fetched rows / total rows = 1/1 - +----------------------------+ - | MINUTE(TIME('01:02:03')) | - |----------------------------| - | 2 | - +----------------------------+ + +--------------------------+ + | MINUTE(TIME('01:02:03')) | + |--------------------------| + | 2 | + +--------------------------+ MINUTE_OF_DAY @@ -1192,11 +1192,11 @@ Example:: os> source=people | eval `MINUTE_OF_DAY(TIME('01:02:03'))` = MINUTE_OF_DAY(TIME('01:02:03')) | fields `MINUTE_OF_DAY(TIME('01:02:03'))` fetched rows / total rows = 1/1 - +-----------------------------------+ - | MINUTE_OF_DAY(TIME('01:02:03')) | - |-----------------------------------| - | 62 | - +-----------------------------------+ + +---------------------------------+ + | MINUTE_OF_DAY(TIME('01:02:03')) | + |---------------------------------| + | 62 | + +---------------------------------+ MINUTE_OF_HOUR @@ -1217,11 +1217,11 @@ Example:: os> source=people | eval `MINUTE_OF_HOUR(TIME('01:02:03'))` = MINUTE_OF_HOUR(TIME('01:02:03')) | fields `MINUTE_OF_HOUR(TIME('01:02:03'))` fetched rows / total rows = 1/1 - +------------------------------------+ - | MINUTE_OF_HOUR(TIME('01:02:03')) | - |------------------------------------| - | 2 | - +------------------------------------+ + +----------------------------------+ + | MINUTE_OF_HOUR(TIME('01:02:03')) | + |----------------------------------| + | 2 | + +----------------------------------+ MONTH @@ -1242,11 +1242,11 @@ Example:: os> source=people | eval `MONTH(DATE('2020-08-26'))` = MONTH(DATE('2020-08-26')) | fields `MONTH(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +-----------------------------+ - | MONTH(DATE('2020-08-26')) | - |-----------------------------| - | 8 | - +-----------------------------+ + +---------------------------+ + | MONTH(DATE('2020-08-26')) | + |---------------------------| + | 8 | + +---------------------------+ MONTH_OF_YEAR @@ -1267,11 +1267,11 @@ Example:: os> source=people | eval `MONTH_OF_YEAR(DATE('2020-08-26'))` = MONTH_OF_YEAR(DATE('2020-08-26')) | fields `MONTH_OF_YEAR(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +-------------------------------------+ - | MONTH_OF_YEAR(DATE('2020-08-26')) | - |-------------------------------------| - | 8 | - +-------------------------------------+ + +-----------------------------------+ + | MONTH_OF_YEAR(DATE('2020-08-26')) | + |-----------------------------------| + | 8 | + +-----------------------------------+ MONTHNAME @@ -1290,11 +1290,11 @@ Example:: os> source=people | eval `MONTHNAME(DATE('2020-08-26'))` = MONTHNAME(DATE('2020-08-26')) | fields `MONTHNAME(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +---------------------------------+ - | MONTHNAME(DATE('2020-08-26')) | - |---------------------------------| - | August | - +---------------------------------+ + +-------------------------------+ + | MONTHNAME(DATE('2020-08-26')) | + |-------------------------------| + | August | + +-------------------------------+ NOW @@ -1337,11 +1337,11 @@ Example:: os> source=people | eval `PERIOD_ADD(200801, 2)` = PERIOD_ADD(200801, 2), `PERIOD_ADD(200801, -12)` = PERIOD_ADD(200801, -12) | fields `PERIOD_ADD(200801, 2)`, `PERIOD_ADD(200801, -12)` fetched rows / total rows = 1/1 - +-------------------------+---------------------------+ - | PERIOD_ADD(200801, 2) | PERIOD_ADD(200801, -12) | - |-------------------------+---------------------------| - | 200803 | 200701 | - +-------------------------+---------------------------+ + +-----------------------+-------------------------+ + | PERIOD_ADD(200801, 2) | PERIOD_ADD(200801, -12) | + |-----------------------+-------------------------| + | 200803 | 200701 | + +-----------------------+-------------------------+ PERIOD_DIFF @@ -1360,11 +1360,11 @@ Example:: os> source=people | eval `PERIOD_DIFF(200802, 200703)` = PERIOD_DIFF(200802, 200703), `PERIOD_DIFF(200802, 201003)` = PERIOD_DIFF(200802, 201003) | fields `PERIOD_DIFF(200802, 200703)`, `PERIOD_DIFF(200802, 201003)` fetched rows / total rows = 1/1 - +-------------------------------+-------------------------------+ - | PERIOD_DIFF(200802, 200703) | PERIOD_DIFF(200802, 201003) | - |-------------------------------+-------------------------------| - | 11 | -25 | - +-------------------------------+-------------------------------+ + +-----------------------------+-----------------------------+ + | PERIOD_DIFF(200802, 200703) | PERIOD_DIFF(200802, 201003) | + |-----------------------------+-----------------------------| + | 11 | -25 | + +-----------------------------+-----------------------------+ QUARTER @@ -1383,11 +1383,11 @@ Example:: os> source=people | eval `QUARTER(DATE('2020-08-26'))` = QUARTER(DATE('2020-08-26')) | fields `QUARTER(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +-------------------------------+ - | QUARTER(DATE('2020-08-26')) | - |-------------------------------| - | 3 | - +-------------------------------+ + +-----------------------------+ + | QUARTER(DATE('2020-08-26')) | + |-----------------------------| + | 3 | + +-----------------------------+ SEC_TO_TIME @@ -1409,11 +1409,11 @@ Example:: os> source=people | eval `SEC_TO_TIME(3601)` = SEC_TO_TIME(3601) | eval `SEC_TO_TIME(1234.123)` = SEC_TO_TIME(1234.123) | fields `SEC_TO_TIME(3601)`, `SEC_TO_TIME(1234.123)` fetched rows / total rows = 1/1 - +---------------------+-------------------------+ - | SEC_TO_TIME(3601) | SEC_TO_TIME(1234.123) | - |---------------------+-------------------------| - | 01:00:01 | 00:20:34.123 | - +---------------------+-------------------------+ + +-------------------+-----------------------+ + | SEC_TO_TIME(3601) | SEC_TO_TIME(1234.123) | + |-------------------+-----------------------| + | 01:00:01 | 00:20:34.123 | + +-------------------+-----------------------+ SECOND @@ -1434,11 +1434,11 @@ Example:: os> source=people | eval `SECOND(TIME('01:02:03'))` = SECOND(TIME('01:02:03')) | fields `SECOND(TIME('01:02:03'))` fetched rows / total rows = 1/1 - +----------------------------+ - | SECOND(TIME('01:02:03')) | - |----------------------------| - | 3 | - +----------------------------+ + +--------------------------+ + | SECOND(TIME('01:02:03')) | + |--------------------------| + | 3 | + +--------------------------+ SECOND_OF_MINUTE @@ -1459,11 +1459,11 @@ Example:: os> source=people | eval `SECOND_OF_MINUTE(TIME('01:02:03'))` = SECOND_OF_MINUTE(TIME('01:02:03')) | fields `SECOND_OF_MINUTE(TIME('01:02:03'))` fetched rows / total rows = 1/1 - +--------------------------------------+ - | SECOND_OF_MINUTE(TIME('01:02:03')) | - |--------------------------------------| - | 3 | - +--------------------------------------+ + +------------------------------------+ + | SECOND_OF_MINUTE(TIME('01:02:03')) | + |------------------------------------| + | 3 | + +------------------------------------+ STR_TO_DATE @@ -1485,11 +1485,11 @@ Example:: OS> source=people | eval `str_to_date("01,5,2013", "%d,%m,%Y")` = str_to_date("01,5,2013", "%d,%m,%Y") | fields = `str_to_date("01,5,2013", "%d,%m,%Y")` fetched rows / total rows = 1/1 - +----------------------------------------+ - | str_to_date("01,5,2013", "%d,%m,%Y") | - |----------------------------------------| - | 2013-05-01 00:00:00 | - +----------------------------------------+ + +--------------------------------------+ + | str_to_date("01,5,2013", "%d,%m,%Y") | + |--------------------------------------| + | 2013-05-01 00:00:00 | + +--------------------------------------+ SUBDATE @@ -1519,11 +1519,11 @@ Example:: os> source=people | eval `'2008-01-02' - 31d` = SUBDATE(DATE('2008-01-02'), INTERVAL 31 DAY), `'2020-08-26' - 1` = SUBDATE(DATE('2020-08-26'), 1), `ts '2020-08-26 01:01:01' - 1` = SUBDATE(TIMESTAMP('2020-08-26 01:01:01'), 1) | fields `'2008-01-02' - 31d`, `'2020-08-26' - 1`, `ts '2020-08-26 01:01:01' - 1` fetched rows / total rows = 1/1 - +----------------------+--------------------+--------------------------------+ - | '2008-01-02' - 31d | '2020-08-26' - 1 | ts '2020-08-26 01:01:01' - 1 | - |----------------------+--------------------+--------------------------------| - | 2007-12-02 00:00:00 | 2020-08-25 | 2020-08-25 01:01:01 | - +----------------------+--------------------+--------------------------------+ + +---------------------+------------------+------------------------------+ + | '2008-01-02' - 31d | '2020-08-26' - 1 | ts '2020-08-26 01:01:01' - 1 | + |---------------------+------------------+------------------------------| + | 2007-12-02 00:00:00 | 2020-08-25 | 2020-08-25 01:01:01 | + +---------------------+------------------+------------------------------+ SUBTIME @@ -1556,35 +1556,35 @@ Example:: os> source=people | eval `'23:59:59' - 0` = SUBTIME(TIME('23:59:59'), DATE('2004-01-01')) | fields `'23:59:59' - 0` fetched rows / total rows = 1/1 - +------------------+ - | '23:59:59' - 0 | - |------------------| - | 23:59:59 | - +------------------+ + +----------------+ + | '23:59:59' - 0 | + |----------------| + | 23:59:59 | + +----------------+ os> source=people | eval `'2004-01-01' - '23:59:59'` = SUBTIME(DATE('2004-01-01'), TIME('23:59:59')) | fields `'2004-01-01' - '23:59:59'` fetched rows / total rows = 1/1 - +-----------------------------+ - | '2004-01-01' - '23:59:59' | - |-----------------------------| - | 2003-12-31 00:00:01 | - +-----------------------------+ - - os> source=people | eval `'10:20:30' - '00:05:42'` = SUBTIME(TIME('10:20:30'), TIME('00:05:42')) | fields `'10:20:30' - '00:05:42'` - fetched rows / total rows = 1/1 +---------------------------+ - | '10:20:30' - '00:05:42' | + | '2004-01-01' - '23:59:59' | |---------------------------| - | 10:14:48 | + | 2003-12-31 00:00:01 | +---------------------------+ + os> source=people | eval `'10:20:30' - '00:05:42'` = SUBTIME(TIME('10:20:30'), TIME('00:05:42')) | fields `'10:20:30' - '00:05:42'` + fetched rows / total rows = 1/1 + +-------------------------+ + | '10:20:30' - '00:05:42' | + |-------------------------| + | 10:14:48 | + +-------------------------+ + os> source=people | eval `'2007-03-01 10:20:30' - '20:40:50'` = SUBTIME(TIMESTAMP('2007-03-01 10:20:30'), TIMESTAMP('2002-03-04 20:40:50')) | fields `'2007-03-01 10:20:30' - '20:40:50'` fetched rows / total rows = 1/1 - +--------------------------------------+ - | '2007-03-01 10:20:30' - '20:40:50' | - |--------------------------------------| - | 2007-02-28 13:39:40 | - +--------------------------------------+ + +------------------------------------+ + | '2007-03-01 10:20:30' - '20:40:50' | + |------------------------------------| + | 2007-02-28 13:39:40 | + +------------------------------------+ SYSDATE @@ -1630,35 +1630,35 @@ Example:: os> source=people | eval `TIME('13:49:00')` = TIME('13:49:00') | fields `TIME('13:49:00')` fetched rows / total rows = 1/1 - +--------------------+ - | TIME('13:49:00') | - |--------------------| - | 13:49:00 | - +--------------------+ + +------------------+ + | TIME('13:49:00') | + |------------------| + | 13:49:00 | + +------------------+ os> source=people | eval `TIME('13:49')` = TIME('13:49') | fields `TIME('13:49')` fetched rows / total rows = 1/1 - +-----------------+ - | TIME('13:49') | - |-----------------| - | 13:49:00 | - +-----------------+ + +---------------+ + | TIME('13:49') | + |---------------| + | 13:49:00 | + +---------------+ os> source=people | eval `TIME('2020-08-26 13:49:00')` = TIME('2020-08-26 13:49:00') | fields `TIME('2020-08-26 13:49:00')` fetched rows / total rows = 1/1 - +-------------------------------+ - | TIME('2020-08-26 13:49:00') | - |-------------------------------| - | 13:49:00 | - +-------------------------------+ + +-----------------------------+ + | TIME('2020-08-26 13:49:00') | + |-----------------------------| + | 13:49:00 | + +-----------------------------+ os> source=people | eval `TIME('2020-08-26 13:49')` = TIME('2020-08-26 13:49') | fields `TIME('2020-08-26 13:49')` fetched rows / total rows = 1/1 - +----------------------------+ - | TIME('2020-08-26 13:49') | - |----------------------------| - | 13:49:00 | - +----------------------------+ + +--------------------------+ + | TIME('2020-08-26 13:49') | + |--------------------------| + | 13:49:00 | + +--------------------------+ TIME_FORMAT @@ -1709,11 +1709,11 @@ Example:: os> source=people | eval `TIME_FORMAT('1998-01-31 13:14:15.012345', '%f %H %h %I %i %p %r %S %s %T')` = TIME_FORMAT('1998-01-31 13:14:15.012345', '%f %H %h %I %i %p %r %S %s %T') | fields `TIME_FORMAT('1998-01-31 13:14:15.012345', '%f %H %h %I %i %p %r %S %s %T')` fetched rows / total rows = 1/1 - +------------------------------------------------------------------------------+ - | TIME_FORMAT('1998-01-31 13:14:15.012345', '%f %H %h %I %i %p %r %S %s %T') | - |------------------------------------------------------------------------------| - | 012345 13 01 01 14 PM 01:14:15 PM 15 15 13:14:15 | - +------------------------------------------------------------------------------+ + +----------------------------------------------------------------------------+ + | TIME_FORMAT('1998-01-31 13:14:15.012345', '%f %H %h %I %i %p %r %S %s %T') | + |----------------------------------------------------------------------------| + | 012345 13 01 01 14 PM 01:14:15 PM 15 15 13:14:15 | + +----------------------------------------------------------------------------+ TIME_TO_SEC @@ -1732,11 +1732,11 @@ Example:: os> source=people | eval `TIME_TO_SEC(TIME('22:23:00'))` = TIME_TO_SEC(TIME('22:23:00')) | fields `TIME_TO_SEC(TIME('22:23:00'))` fetched rows / total rows = 1/1 - +---------------------------------+ - | TIME_TO_SEC(TIME('22:23:00')) | - |---------------------------------| - | 80580 | - +---------------------------------+ + +-------------------------------+ + | TIME_TO_SEC(TIME('22:23:00')) | + |-------------------------------| + | 80580 | + +-------------------------------+ TIMEDIFF @@ -1755,11 +1755,11 @@ Example:: os> source=people | eval `TIMEDIFF('23:59:59', '13:00:00')` = TIMEDIFF('23:59:59', '13:00:00') | fields `TIMEDIFF('23:59:59', '13:00:00')` fetched rows / total rows = 1/1 - +------------------------------------+ - | TIMEDIFF('23:59:59', '13:00:00') | - |------------------------------------| - | 10:59:59 | - +------------------------------------+ + +----------------------------------+ + | TIMEDIFF('23:59:59', '13:00:00') | + |----------------------------------| + | 10:59:59 | + +----------------------------------+ TIMESTAMP @@ -1783,11 +1783,11 @@ Example:: os> source=people | eval `TIMESTAMP('2020-08-26 13:49:00')` = TIMESTAMP('2020-08-26 13:49:00'), `TIMESTAMP('2020-08-26 13:49:00', TIME('12:15:42'))` = TIMESTAMP('2020-08-26 13:49:00', TIME('12:15:42')) | fields `TIMESTAMP('2020-08-26 13:49:00')`, `TIMESTAMP('2020-08-26 13:49:00', TIME('12:15:42'))` fetched rows / total rows = 1/1 - +------------------------------------+------------------------------------------------------+ - | TIMESTAMP('2020-08-26 13:49:00') | TIMESTAMP('2020-08-26 13:49:00', TIME('12:15:42')) | - |------------------------------------+------------------------------------------------------| - | 2020-08-26 13:49:00 | 2020-08-27 02:04:42 | - +------------------------------------+------------------------------------------------------+ + +----------------------------------+----------------------------------------------------+ + | TIMESTAMP('2020-08-26 13:49:00') | TIMESTAMP('2020-08-26 13:49:00', TIME('12:15:42')) | + |----------------------------------+----------------------------------------------------| + | 2020-08-26 13:49:00 | 2020-08-27 02:04:42 | + +----------------------------------+----------------------------------------------------+ TIMESTAMPADD @@ -1808,11 +1808,11 @@ Examples:: os> source=people | eval `TIMESTAMPADD(DAY, 17, '2000-01-01 00:00:00')` = TIMESTAMPADD(DAY, 17, '2000-01-01 00:00:00') | eval `TIMESTAMPADD(QUARTER, -1, '2000-01-01 00:00:00')` = TIMESTAMPADD(QUARTER, -1, '2000-01-01 00:00:00') | fields `TIMESTAMPADD(DAY, 17, '2000-01-01 00:00:00')`, `TIMESTAMPADD(QUARTER, -1, '2000-01-01 00:00:00')` fetched rows / total rows = 1/1 - +------------------------------------------------+----------------------------------------------------+ - | TIMESTAMPADD(DAY, 17, '2000-01-01 00:00:00') | TIMESTAMPADD(QUARTER, -1, '2000-01-01 00:00:00') | - |------------------------------------------------+----------------------------------------------------| - | 2000-01-18 00:00:00 | 1999-10-01 00:00:00 | - +------------------------------------------------+----------------------------------------------------+ + +----------------------------------------------+--------------------------------------------------+ + | TIMESTAMPADD(DAY, 17, '2000-01-01 00:00:00') | TIMESTAMPADD(QUARTER, -1, '2000-01-01 00:00:00') | + |----------------------------------------------+--------------------------------------------------| + | 2000-01-18 00:00:00 | 1999-10-01 00:00:00 | + +----------------------------------------------+--------------------------------------------------+ TIMESTAMPDIFF @@ -1834,11 +1834,11 @@ Examples:: os> source=people | eval `TIMESTAMPDIFF(YEAR, '1997-01-01 00:00:00', '2001-03-06 00:00:00')` = TIMESTAMPDIFF(YEAR, '1997-01-01 00:00:00', '2001-03-06 00:00:00') | eval `TIMESTAMPDIFF(SECOND, time('00:00:23'), time('00:00:00'))` = TIMESTAMPDIFF(SECOND, time('00:00:23'), time('00:00:00')) | fields `TIMESTAMPDIFF(YEAR, '1997-01-01 00:00:00', '2001-03-06 00:00:00')`, `TIMESTAMPDIFF(SECOND, time('00:00:23'), time('00:00:00'))` fetched rows / total rows = 1/1 - +---------------------------------------------------------------------+-------------------------------------------------------------+ - | TIMESTAMPDIFF(YEAR, '1997-01-01 00:00:00', '2001-03-06 00:00:00') | TIMESTAMPDIFF(SECOND, time('00:00:23'), time('00:00:00')) | - |---------------------------------------------------------------------+-------------------------------------------------------------| - | 4 | -23 | - +---------------------------------------------------------------------+-------------------------------------------------------------+ + +-------------------------------------------------------------------+-----------------------------------------------------------+ + | TIMESTAMPDIFF(YEAR, '1997-01-01 00:00:00', '2001-03-06 00:00:00') | TIMESTAMPDIFF(SECOND, time('00:00:23'), time('00:00:00')) | + |-------------------------------------------------------------------+-----------------------------------------------------------| + | 4 | -23 | + +-------------------------------------------------------------------+-----------------------------------------------------------+ TO_DAYS @@ -1857,11 +1857,11 @@ Example:: os> source=people | eval `TO_DAYS(DATE('2008-10-07'))` = TO_DAYS(DATE('2008-10-07')) | fields `TO_DAYS(DATE('2008-10-07'))` fetched rows / total rows = 1/1 - +-------------------------------+ - | TO_DAYS(DATE('2008-10-07')) | - |-------------------------------| - | 733687 | - +-------------------------------+ + +-----------------------------+ + | TO_DAYS(DATE('2008-10-07')) | + |-----------------------------| + | 733687 | + +-----------------------------+ TO_SECONDS @@ -1881,11 +1881,11 @@ Example:: os> source=people | eval `TO_SECONDS(DATE('2008-10-07'))` = TO_SECONDS(DATE('2008-10-07')) | eval `TO_SECONDS(950228)` = TO_SECONDS(950228) | fields `TO_SECONDS(DATE('2008-10-07'))`, `TO_SECONDS(950228)` fetched rows / total rows = 1/1 - +----------------------------------+----------------------+ - | TO_SECONDS(DATE('2008-10-07')) | TO_SECONDS(950228) | - |----------------------------------+----------------------| - | 63390556800 | 62961148800 | - +----------------------------------+----------------------+ + +--------------------------------+--------------------+ + | TO_SECONDS(DATE('2008-10-07')) | TO_SECONDS(950228) | + |--------------------------------+--------------------| + | 63390556800 | 62961148800 | + +--------------------------------+--------------------+ UNIX_TIMESTAMP @@ -1907,11 +1907,11 @@ Example:: os> source=people | eval `UNIX_TIMESTAMP(double)` = UNIX_TIMESTAMP(20771122143845), `UNIX_TIMESTAMP(timestamp)` = UNIX_TIMESTAMP(TIMESTAMP('1996-11-15 17:05:42')) | fields `UNIX_TIMESTAMP(double)`, `UNIX_TIMESTAMP(timestamp)` fetched rows / total rows = 1/1 - +--------------------------+-----------------------------+ - | UNIX_TIMESTAMP(double) | UNIX_TIMESTAMP(timestamp) | - |--------------------------+-----------------------------| - | 3404817525.0 | 848077542.0 | - +--------------------------+-----------------------------+ + +------------------------+---------------------------+ + | UNIX_TIMESTAMP(double) | UNIX_TIMESTAMP(timestamp) | + |------------------------+---------------------------| + | 3404817525.0 | 848077542.0 | + +------------------------+---------------------------+ UTC_DATE @@ -1930,11 +1930,11 @@ Example:: > source=people | eval `UTC_DATE()` = UTC_DATE() | fields `UTC_DATE()` fetched rows / total rows = 1/1 - +--------------+ - | UTC_DATE() | - |--------------| - | 2022-10-03 | - +--------------+ + +------------+ + | UTC_DATE() | + |------------| + | 2022-10-03 | + +------------+ UTC_TIME @@ -1953,11 +1953,11 @@ Example:: > source=people | eval `UTC_TIME()` = UTC_TIME() | fields `UTC_TIME()` fetched rows / total rows = 1/1 - +--------------+ - | UTC_TIME() | - |--------------| - | 17:54:27 | - +--------------+ + +------------+ + | UTC_TIME() | + |------------| + | 17:54:27 | + +------------+ UTC_TIMESTAMP @@ -2042,11 +2042,11 @@ Example:: os> source=people | eval `WEEK(DATE('2008-02-20'))` = WEEK(DATE('2008-02-20')), `WEEK(DATE('2008-02-20'), 1)` = WEEK(DATE('2008-02-20'), 1) | fields `WEEK(DATE('2008-02-20'))`, `WEEK(DATE('2008-02-20'), 1)` fetched rows / total rows = 1/1 - +----------------------------+-------------------------------+ - | WEEK(DATE('2008-02-20')) | WEEK(DATE('2008-02-20'), 1) | - |----------------------------+-------------------------------| - | 7 | 8 | - +----------------------------+-------------------------------+ + +--------------------------+-----------------------------+ + | WEEK(DATE('2008-02-20')) | WEEK(DATE('2008-02-20'), 1) | + |--------------------------+-----------------------------| + | 7 | 8 | + +--------------------------+-----------------------------+ WEEKDAY @@ -2067,11 +2067,11 @@ Example:: os> source=people | eval `weekday(DATE('2020-08-26'))` = weekday(DATE('2020-08-26')) | eval `weekday(DATE('2020-08-27'))` = weekday(DATE('2020-08-27')) | fields `weekday(DATE('2020-08-26'))`, `weekday(DATE('2020-08-27'))` fetched rows / total rows = 1/1 - +-------------------------------+-------------------------------+ - | weekday(DATE('2020-08-26')) | weekday(DATE('2020-08-27')) | - |-------------------------------+-------------------------------| - | 2 | 3 | - +-------------------------------+-------------------------------+ + +-----------------------------+-----------------------------+ + | weekday(DATE('2020-08-26')) | weekday(DATE('2020-08-27')) | + |-----------------------------+-----------------------------| + | 2 | 3 | + +-----------------------------+-----------------------------+ WEEK_OF_YEAR @@ -2133,11 +2133,11 @@ Example:: os> source=people | eval `WEEK_OF_YEAR(DATE('2008-02-20'))` = WEEK(DATE('2008-02-20')), `WEEK_OF_YEAR(DATE('2008-02-20'), 1)` = WEEK_OF_YEAR(DATE('2008-02-20'), 1) | fields `WEEK_OF_YEAR(DATE('2008-02-20'))`, `WEEK_OF_YEAR(DATE('2008-02-20'), 1)` fetched rows / total rows = 1/1 - +------------------------------------+---------------------------------------+ - | WEEK_OF_YEAR(DATE('2008-02-20')) | WEEK_OF_YEAR(DATE('2008-02-20'), 1) | - |------------------------------------+---------------------------------------| - | 7 | 8 | - +------------------------------------+---------------------------------------+ + +----------------------------------+-------------------------------------+ + | WEEK_OF_YEAR(DATE('2008-02-20')) | WEEK_OF_YEAR(DATE('2008-02-20'), 1) | + |----------------------------------+-------------------------------------| + | 7 | 8 | + +----------------------------------+-------------------------------------+ YEAR @@ -2156,11 +2156,11 @@ Example:: os> source=people | eval `YEAR(DATE('2020-08-26'))` = YEAR(DATE('2020-08-26')) | fields `YEAR(DATE('2020-08-26'))` fetched rows / total rows = 1/1 - +----------------------------+ - | YEAR(DATE('2020-08-26')) | - |----------------------------| - | 2020 | - +----------------------------+ + +--------------------------+ + | YEAR(DATE('2020-08-26')) | + |--------------------------| + | 2020 | + +--------------------------+ YEARWEEK @@ -2179,10 +2179,10 @@ Example:: os> source=people | eval `YEARWEEK('2020-08-26')` = YEARWEEK('2020-08-26') | eval `YEARWEEK('2019-01-05', 1)` = YEARWEEK('2019-01-05', 1) | fields `YEARWEEK('2020-08-26')`, `YEARWEEK('2019-01-05', 1)` fetched rows / total rows = 1/1 - +--------------------------+-----------------------------+ - | YEARWEEK('2020-08-26') | YEARWEEK('2019-01-05', 1) | - |--------------------------+-----------------------------| - | 202034 | 201901 | - +--------------------------+-----------------------------+ + +------------------------+---------------------------+ + | YEARWEEK('2020-08-26') | YEARWEEK('2019-01-05', 1) | + |------------------------+---------------------------| + | 202034 | 201901 | + +------------------------+---------------------------+ diff --git a/docs/user/ppl/functions/expressions.rst b/docs/user/ppl/functions/expressions.rst index ac48324680..d25063d559 100644 --- a/docs/user/ppl/functions/expressions.rst +++ b/docs/user/ppl/functions/expressions.rst @@ -48,13 +48,13 @@ Here is an example for different type of arithmetic expressions:: os> source=accounts | where age > (25 + 5) | fields age ; fetched rows / total rows = 3/3 - +-------+ - | age | - |-------| - | 32 | - | 36 | - | 33 | - +-------+ + +-----+ + | age | + |-----| + | 32 | + | 36 | + | 33 | + +-----+ Predicate Operators =================== @@ -108,11 +108,11 @@ Here is an example for comparison operators:: os> source=accounts | where age > 33 | fields age ; fetched rows / total rows = 1/1 - +-------+ - | age | - |-------| - | 36 | - +-------+ + +-----+ + | age | + |-----| + | 36 | + +-----+ IN @@ -122,12 +122,12 @@ IN operator test field in value lists:: os> source=accounts | where age in (32, 33) | fields age ; fetched rows / total rows = 2/2 - +-------+ - | age | - |-------| - | 32 | - | 33 | - +-------+ + +-----+ + | age | + |-----| + | 32 | + | 33 | + +-----+ OR @@ -137,12 +137,12 @@ OR operator :: os> source=accounts | where age = 32 OR age = 33 | fields age ; fetched rows / total rows = 2/2 - +-------+ - | age | - |-------| - | 32 | - | 33 | - +-------+ + +-----+ + | age | + |-----| + | 32 | + | 33 | + +-----+ NOT @@ -152,10 +152,10 @@ NOT operator :: os> source=accounts | where not age in (32, 33) | fields age ; fetched rows / total rows = 2/2 - +-------+ - | age | - |-------| - | 36 | - | 28 | - +-------+ + +-----+ + | age | + |-----| + | 36 | + | 28 | + +-----+ diff --git a/docs/user/ppl/functions/math.rst b/docs/user/ppl/functions/math.rst index c5eb07b5da..65f544461b 100644 --- a/docs/user/ppl/functions/math.rst +++ b/docs/user/ppl/functions/math.rst @@ -25,11 +25,11 @@ Example:: os> source=people | eval `ABS(-1)` = ABS(-1) | fields `ABS(-1)` fetched rows / total rows = 1/1 - +-----------+ - | ABS(-1) | - |-----------| - | 1 | - +-----------+ + +---------+ + | ABS(-1) | + |---------| + | 1 | + +---------+ ACOS @@ -71,11 +71,11 @@ Example:: os> source=people | eval `ASIN(0)` = ASIN(0) | fields `ASIN(0)` fetched rows / total rows = 1/1 - +-----------+ - | ASIN(0) | - |-----------| - | 0.0 | - +-----------+ + +---------+ + | ASIN(0) | + |---------| + | 0.0 | + +---------+ ATAN @@ -150,19 +150,19 @@ Example:: os> source=people | eval `CEILING(0)` = CEILING(0), `CEILING(50.00005)` = CEILING(50.00005), `CEILING(-50.00005)` = CEILING(-50.00005) | fields `CEILING(0)`, `CEILING(50.00005)`, `CEILING(-50.00005)` fetched rows / total rows = 1/1 - +--------------+---------------------+----------------------+ - | CEILING(0) | CEILING(50.00005) | CEILING(-50.00005) | - |--------------+---------------------+----------------------| - | 0 | 51 | -50 | - +--------------+---------------------+----------------------+ + +------------+-------------------+--------------------+ + | CEILING(0) | CEILING(50.00005) | CEILING(-50.00005) | + |------------+-------------------+--------------------| + | 0 | 51 | -50 | + +------------+-------------------+--------------------+ os> source=people | eval `CEILING(3147483647.12345)` = CEILING(3147483647.12345), `CEILING(113147483647.12345)` = CEILING(113147483647.12345), `CEILING(3147483647.00001)` = CEILING(3147483647.00001) | fields `CEILING(3147483647.12345)`, `CEILING(113147483647.12345)`, `CEILING(3147483647.00001)` fetched rows / total rows = 1/1 - +-----------------------------+-------------------------------+-----------------------------+ - | CEILING(3147483647.12345) | CEILING(113147483647.12345) | CEILING(3147483647.00001) | - |-----------------------------+-------------------------------+-----------------------------| - | 3147483648 | 113147483648 | 3147483648 | - +-----------------------------+-------------------------------+-----------------------------+ + +---------------------------+-----------------------------+---------------------------+ + | CEILING(3147483647.12345) | CEILING(113147483647.12345) | CEILING(3147483647.00001) | + |---------------------------+-----------------------------+---------------------------| + | 3147483648 | 113147483648 | 3147483648 | + +---------------------------+-----------------------------+---------------------------+ CONV @@ -181,11 +181,11 @@ Example:: os> source=people | eval `CONV('12', 10, 16)` = CONV('12', 10, 16), `CONV('2C', 16, 10)` = CONV('2C', 16, 10), `CONV(12, 10, 2)` = CONV(12, 10, 2), `CONV(1111, 2, 10)` = CONV(1111, 2, 10) | fields `CONV('12', 10, 16)`, `CONV('2C', 16, 10)`, `CONV(12, 10, 2)`, `CONV(1111, 2, 10)` fetched rows / total rows = 1/1 - +----------------------+----------------------+-------------------+---------------------+ - | CONV('12', 10, 16) | CONV('2C', 16, 10) | CONV(12, 10, 2) | CONV(1111, 2, 10) | - |----------------------+----------------------+-------------------+---------------------| - | c | 44 | 1100 | 15 | - +----------------------+----------------------+-------------------+---------------------+ + +--------------------+--------------------+-----------------+-------------------+ + | CONV('12', 10, 16) | CONV('2C', 16, 10) | CONV(12, 10, 2) | CONV(1111, 2, 10) | + |--------------------+--------------------+-----------------+-------------------| + | c | 44 | 1100 | 15 | + +--------------------+--------------------+-----------------+-------------------+ COS @@ -204,11 +204,11 @@ Example:: os> source=people | eval `COS(0)` = COS(0) | fields `COS(0)` fetched rows / total rows = 1/1 - +----------+ - | COS(0) | - |----------| - | 1.0 | - +----------+ + +--------+ + | COS(0) | + |--------| + | 1.0 | + +--------+ COT @@ -250,11 +250,11 @@ Example:: os> source=people | eval `CRC32('MySQL')` = CRC32('MySQL') | fields `CRC32('MySQL')` fetched rows / total rows = 1/1 - +------------------+ - | CRC32('MySQL') | - |------------------| - | 3259397556 | - +------------------+ + +----------------+ + | CRC32('MySQL') | + |----------------| + | 3259397556 | + +----------------+ DEGREES @@ -342,27 +342,27 @@ Example:: os> source=people | eval `FLOOR(0)` = FLOOR(0), `FLOOR(50.00005)` = FLOOR(50.00005), `FLOOR(-50.00005)` = FLOOR(-50.00005) | fields `FLOOR(0)`, `FLOOR(50.00005)`, `FLOOR(-50.00005)` fetched rows / total rows = 1/1 - +------------+-------------------+--------------------+ - | FLOOR(0) | FLOOR(50.00005) | FLOOR(-50.00005) | - |------------+-------------------+--------------------| - | 0 | 50 | -51 | - +------------+-------------------+--------------------+ + +----------+-----------------+------------------+ + | FLOOR(0) | FLOOR(50.00005) | FLOOR(-50.00005) | + |----------+-----------------+------------------| + | 0 | 50 | -51 | + +----------+-----------------+------------------+ os> source=people | eval `FLOOR(3147483647.12345)` = FLOOR(3147483647.12345), `FLOOR(113147483647.12345)` = FLOOR(113147483647.12345), `FLOOR(3147483647.00001)` = FLOOR(3147483647.00001) | fields `FLOOR(3147483647.12345)`, `FLOOR(113147483647.12345)`, `FLOOR(3147483647.00001)` fetched rows / total rows = 1/1 - +---------------------------+-----------------------------+---------------------------+ - | FLOOR(3147483647.12345) | FLOOR(113147483647.12345) | FLOOR(3147483647.00001) | - |---------------------------+-----------------------------+---------------------------| - | 3147483647 | 113147483647 | 3147483647 | - +---------------------------+-----------------------------+---------------------------+ + +-------------------------+---------------------------+-------------------------+ + | FLOOR(3147483647.12345) | FLOOR(113147483647.12345) | FLOOR(3147483647.00001) | + |-------------------------+---------------------------+-------------------------| + | 3147483647 | 113147483647 | 3147483647 | + +-------------------------+---------------------------+-------------------------+ os> source=people | eval `FLOOR(282474973688888.022)` = FLOOR(282474973688888.022), `FLOOR(9223372036854775807.022)` = FLOOR(9223372036854775807.022), `FLOOR(9223372036854775807.0000001)` = FLOOR(9223372036854775807.0000001) | fields `FLOOR(282474973688888.022)`, `FLOOR(9223372036854775807.022)`, `FLOOR(9223372036854775807.0000001)` fetched rows / total rows = 1/1 - +------------------------------+----------------------------------+--------------------------------------+ - | FLOOR(282474973688888.022) | FLOOR(9223372036854775807.022) | FLOOR(9223372036854775807.0000001) | - |------------------------------+----------------------------------+--------------------------------------| - | 282474973688888 | 9223372036854775807 | 9223372036854775807 | - +------------------------------+----------------------------------+--------------------------------------+ + +----------------------------+--------------------------------+------------------------------------+ + | FLOOR(282474973688888.022) | FLOOR(9223372036854775807.022) | FLOOR(9223372036854775807.0000001) | + |----------------------------+--------------------------------+------------------------------------| + | 282474973688888 | 9223372036854775807 | 9223372036854775807 | + +----------------------------+--------------------------------+------------------------------------+ LN @@ -406,11 +406,11 @@ Example:: os> source=people | eval `LOG(2)` = LOG(2), `LOG(2, 8)` = LOG(2, 8) | fields `LOG(2)`, `LOG(2, 8)` fetched rows / total rows = 1/1 - +--------------------+-------------+ - | LOG(2) | LOG(2, 8) | - |--------------------+-------------| - | 0.6931471805599453 | 3.0 | - +--------------------+-------------+ + +--------------------+-----------+ + | LOG(2) | LOG(2, 8) | + |--------------------+-----------| + | 0.6931471805599453 | 3.0 | + +--------------------+-----------+ LOG2 @@ -431,11 +431,11 @@ Example:: os> source=people | eval `LOG2(8)` = LOG2(8) | fields `LOG2(8)` fetched rows / total rows = 1/1 - +-----------+ - | LOG2(8) | - |-----------| - | 3.0 | - +-----------+ + +---------+ + | LOG2(8) | + |---------| + | 3.0 | + +---------+ LOG10 @@ -456,11 +456,11 @@ Example:: os> source=people | eval `LOG10(100)` = LOG10(100) | fields `LOG10(100)` fetched rows / total rows = 1/1 - +--------------+ - | LOG10(100) | - |--------------| - | 2.0 | - +--------------+ + +------------+ + | LOG10(100) | + |------------| + | 2.0 | + +------------+ MOD @@ -479,11 +479,11 @@ Example:: os> source=people | eval `MOD(3, 2)` = MOD(3, 2), `MOD(3.1, 2)` = MOD(3.1, 2) | fields `MOD(3, 2)`, `MOD(3.1, 2)` fetched rows / total rows = 1/1 - +-------------+---------------+ - | MOD(3, 2) | MOD(3.1, 2) | - |-------------+---------------| - | 1 | 1.1 | - +-------------+---------------+ + +-----------+-------------+ + | MOD(3, 2) | MOD(3.1, 2) | + |-----------+-------------| + | 1 | 1.1 | + +-----------+-------------+ PI @@ -525,11 +525,11 @@ Example:: os> source=people | eval `POW(3, 2)` = POW(3, 2), `POW(-3, 2)` = POW(-3, 2), `POW(3, -2)` = POW(3, -2) | fields `POW(3, 2)`, `POW(-3, 2)`, `POW(3, -2)` fetched rows / total rows = 1/1 - +-------------+--------------+--------------------+ - | POW(3, 2) | POW(-3, 2) | POW(3, -2) | - |-------------+--------------+--------------------| - | 9.0 | 9.0 | 0.1111111111111111 | - +-------------+--------------+--------------------+ + +-----------+------------+--------------------+ + | POW(3, 2) | POW(-3, 2) | POW(3, -2) | + |-----------+------------+--------------------| + | 9.0 | 9.0 | 0.1111111111111111 | + +-----------+------------+--------------------+ POWER @@ -550,11 +550,11 @@ Example:: os> source=people | eval `POWER(3, 2)` = POWER(3, 2), `POWER(-3, 2)` = POWER(-3, 2), `POWER(3, -2)` = POWER(3, -2) | fields `POWER(3, 2)`, `POWER(-3, 2)`, `POWER(3, -2)` fetched rows / total rows = 1/1 - +---------------+----------------+--------------------+ - | POWER(3, 2) | POWER(-3, 2) | POWER(3, -2) | - |---------------+----------------+--------------------| - | 9.0 | 9.0 | 0.1111111111111111 | - +---------------+----------------+--------------------+ + +-------------+--------------+--------------------+ + | POWER(3, 2) | POWER(-3, 2) | POWER(3, -2) | + |-------------+--------------+--------------------| + | 9.0 | 9.0 | 0.1111111111111111 | + +-------------+--------------+--------------------+ RADIANS @@ -622,11 +622,11 @@ Example:: os> source=people | eval `ROUND(12.34)` = ROUND(12.34), `ROUND(12.34, 1)` = ROUND(12.34, 1), `ROUND(12.34, -1)` = ROUND(12.34, -1), `ROUND(12, 1)` = ROUND(12, 1) | fields `ROUND(12.34)`, `ROUND(12.34, 1)`, `ROUND(12.34, -1)`, `ROUND(12, 1)` fetched rows / total rows = 1/1 - +----------------+-------------------+--------------------+----------------+ - | ROUND(12.34) | ROUND(12.34, 1) | ROUND(12.34, -1) | ROUND(12, 1) | - |----------------+-------------------+--------------------+----------------| - | 12.0 | 12.3 | 10.0 | 12 | - +----------------+-------------------+--------------------+----------------+ + +--------------+-----------------+------------------+--------------+ + | ROUND(12.34) | ROUND(12.34, 1) | ROUND(12.34, -1) | ROUND(12, 1) | + |--------------+-----------------+------------------+--------------| + | 12.0 | 12.3 | 10.0 | 12 | + +--------------+-----------------+------------------+--------------+ SIGN @@ -645,11 +645,11 @@ Example:: os> source=people | eval `SIGN(1)` = SIGN(1), `SIGN(0)` = SIGN(0), `SIGN(-1.1)` = SIGN(-1.1) | fields `SIGN(1)`, `SIGN(0)`, `SIGN(-1.1)` fetched rows / total rows = 1/1 - +-----------+-----------+--------------+ - | SIGN(1) | SIGN(0) | SIGN(-1.1) | - |-----------+-----------+--------------| - | 1 | 0 | -1 | - +-----------+-----------+--------------+ + +---------+---------+------------+ + | SIGN(1) | SIGN(0) | SIGN(-1.1) | + |---------+---------+------------| + | 1 | 0 | -1 | + +---------+---------+------------+ SIN @@ -668,11 +668,11 @@ Example:: os> source=people | eval `SIN(0)` = SIN(0) | fields `SIN(0)` fetched rows / total rows = 1/1 - +----------+ - | SIN(0) | - |----------| - | 0.0 | - +----------+ + +--------+ + | SIN(0) | + |--------| + | 0.0 | + +--------+ SQRT @@ -694,11 +694,11 @@ Example:: os> source=people | eval `SQRT(4)` = SQRT(4), `SQRT(4.41)` = SQRT(4.41) | fields `SQRT(4)`, `SQRT(4.41)` fetched rows / total rows = 1/1 - +-----------+--------------+ - | SQRT(4) | SQRT(4.41) | - |-----------+--------------| - | 2.0 | 2.1 | - +-----------+--------------+ + +---------+------------+ + | SQRT(4) | SQRT(4.41) | + |---------+------------| + | 2.0 | 2.1 | + +---------+------------+ CBRT @@ -719,9 +719,9 @@ Example:: opensearchsql> source=location | eval `CBRT(8)` = CBRT(8), `CBRT(9.261)` = CBRT(9.261), `CBRT(-27)` = CBRT(-27) | fields `CBRT(8)`, `CBRT(9.261)`, `CBRT(-27)`; fetched rows / total rows = 2/2 - +-----------+---------------+-------------+ - | CBRT(8) | CBRT(9.261) | CBRT(-27) | - |-----------+---------------+-------------| - | 2.0 | 2.1 | -3.0 | - | 2.0 | 2.1 | -3.0 | - +-----------+---------------+-------------+ + +---------+-------------+-----------+ + | CBRT(8) | CBRT(9.261) | CBRT(-27) | + |---------+-------------+-----------| + | 2.0 | 2.1 | -3.0 | + | 2.0 | 2.1 | -3.0 | + +---------+-------------+-----------+ diff --git a/docs/user/ppl/functions/relevance.rst b/docs/user/ppl/functions/relevance.rst index fb31edb0d2..a1f240ee05 100644 --- a/docs/user/ppl/functions/relevance.rst +++ b/docs/user/ppl/functions/relevance.rst @@ -37,12 +37,12 @@ Example with only ``field`` and ``query`` expressions, and all other parameters os> source=accounts | where match(address, 'Street') | fields lastname, address; fetched rows / total rows = 2/2 - +------------+--------------------+ - | lastname | address | - |------------+--------------------| - | Bond | 671 Bristol Street | - | Bates | 789 Madison Street | - +------------+--------------------+ + +----------+--------------------+ + | lastname | address | + |----------+--------------------| + | Bond | 671 Bristol Street | + | Bates | 789 Madison Street | + +----------+--------------------+ @@ -50,11 +50,11 @@ Another example to show how to set custom values for the optional parameters:: os> source=accounts | where match(firstname, 'Hattie', operator='AND', boost=2.0) | fields lastname; fetched rows / total rows = 1/1 - +------------+ - | lastname | - |------------| - | Bond | - +------------+ + +----------+ + | lastname | + |----------| + | Bond | + +----------+ MATCH_PHRASE @@ -175,22 +175,22 @@ Example with only ``fields`` and ``query`` expressions, and all other parameters os> source=books | where multi_match(['title'], 'Pooh House') | fields id, title, author; fetched rows / total rows = 2/2 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - | 2 | Winnie-the-Pooh | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + | 2 | Winnie-the-Pooh | Alan Alexander Milne | + +----+--------------------------+----------------------+ Another example to show how to set custom values for the optional parameters:: os> source=books | where multi_match(['title'], 'Pooh House', operator='AND', analyzer=default) | fields id, title, author; fetched rows / total rows = 1/1 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + +----+--------------------------+----------------------+ SIMPLE_QUERY_STRING @@ -228,22 +228,22 @@ Example with only ``fields`` and ``query`` expressions, and all other parameters os> source=books | where simple_query_string(['title'], 'Pooh House') | fields id, title, author; fetched rows / total rows = 2/2 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - | 2 | Winnie-the-Pooh | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + | 2 | Winnie-the-Pooh | Alan Alexander Milne | + +----+--------------------------+----------------------+ Another example to show how to set custom values for the optional parameters:: os> source=books | where simple_query_string(['title'], 'Pooh House', flags='ALL', default_operator='AND') | fields id, title, author; fetched rows / total rows = 1/1 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + +----+--------------------------+----------------------+ MATCH_BOOL_PREFIX @@ -270,22 +270,22 @@ Example with only ``field`` and ``query`` expressions, and all other parameters os> source=accounts | where match_bool_prefix(address, 'Bristol Stre') | fields firstname, address fetched rows / total rows = 2/2 - +-------------+--------------------+ - | firstname | address | - |-------------+--------------------| - | Hattie | 671 Bristol Street | - | Nanette | 789 Madison Street | - +-------------+--------------------+ + +-----------+--------------------+ + | firstname | address | + |-----------+--------------------| + | Hattie | 671 Bristol Street | + | Nanette | 789 Madison Street | + +-----------+--------------------+ Another example to show how to set custom values for the optional parameters:: os> source=accounts | where match_bool_prefix(address, 'Bristol Stre', minimum_should_match = 2) | fields firstname, address fetched rows / total rows = 1/1 - +-------------+--------------------+ - | firstname | address | - |-------------+--------------------| - | Hattie | 671 Bristol Street | - +-------------+--------------------+ + +-----------+--------------------+ + | firstname | address | + |-----------+--------------------| + | Hattie | 671 Bristol Street | + +-----------+--------------------+ QUERY_STRING @@ -335,22 +335,22 @@ Example with only ``fields`` and ``query`` expressions, and all other parameters os> source=books | where query_string(['title'], 'Pooh House') | fields id, title, author; fetched rows / total rows = 2/2 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - | 2 | Winnie-the-Pooh | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + | 2 | Winnie-the-Pooh | Alan Alexander Milne | + +----+--------------------------+----------------------+ Another example to show how to set custom values for the optional parameters:: os> source=books | where query_string(['title'], 'Pooh House', default_operator='AND') | fields id, title, author; fetched rows / total rows = 1/1 - +------+--------------------------+----------------------+ - | id | title | author | - |------+--------------------------+----------------------| - | 1 | The House at Pooh Corner | Alan Alexander Milne | - +------+--------------------------+----------------------+ + +----+--------------------------+----------------------+ + | id | title | author | + |----+--------------------------+----------------------| + | 1 | The House at Pooh Corner | Alan Alexander Milne | + +----+--------------------------+----------------------+ Limitations >>>>>>>>>>> diff --git a/docs/user/ppl/functions/string.rst b/docs/user/ppl/functions/string.rst index edf5220f4f..0dbb09cbb8 100644 --- a/docs/user/ppl/functions/string.rst +++ b/docs/user/ppl/functions/string.rst @@ -24,11 +24,11 @@ Example:: os> source=people | eval `CONCAT('hello', 'world')` = CONCAT('hello', 'world'), `CONCAT('hello ', 'whole ', 'world', '!')` = CONCAT('hello ', 'whole ', 'world', '!') | fields `CONCAT('hello', 'world')`, `CONCAT('hello ', 'whole ', 'world', '!')` fetched rows / total rows = 1/1 - +----------------------------+--------------------------------------------+ - | CONCAT('hello', 'world') | CONCAT('hello ', 'whole ', 'world', '!') | - |----------------------------+--------------------------------------------| - | helloworld | hello whole world! | - +----------------------------+--------------------------------------------+ + +--------------------------+------------------------------------------+ + | CONCAT('hello', 'world') | CONCAT('hello ', 'whole ', 'world', '!') | + |--------------------------+------------------------------------------| + | helloworld | hello whole world! | + +--------------------------+------------------------------------------+ CONCAT_WS @@ -47,11 +47,11 @@ Example:: os> source=people | eval `CONCAT_WS(',', 'hello', 'world')` = CONCAT_WS(',', 'hello', 'world') | fields `CONCAT_WS(',', 'hello', 'world')` fetched rows / total rows = 1/1 - +------------------------------------+ - | CONCAT_WS(',', 'hello', 'world') | - |------------------------------------| - | hello,world | - +------------------------------------+ + +----------------------------------+ + | CONCAT_WS(',', 'hello', 'world') | + |----------------------------------| + | hello,world | + +----------------------------------+ LENGTH @@ -74,11 +74,11 @@ Example:: os> source=people | eval `LENGTH('helloworld')` = LENGTH('helloworld') | fields `LENGTH('helloworld')` fetched rows / total rows = 1/1 - +------------------------+ - | LENGTH('helloworld') | - |------------------------| - | 10 | - +------------------------+ + +----------------------+ + | LENGTH('helloworld') | + |----------------------| + | 10 | + +----------------------+ LIKE @@ -98,11 +98,11 @@ Example:: os> source=people | eval `LIKE('hello world', '_ello%')` = LIKE('hello world', '_ELLO%') | fields `LIKE('hello world', '_ello%')` fetched rows / total rows = 1/1 - +---------------------------------+ - | LIKE('hello world', '_ello%') | - |---------------------------------| - | True | - +---------------------------------+ + +-------------------------------+ + | LIKE('hello world', '_ello%') | + |-------------------------------| + | True | + +-------------------------------+ LOWER @@ -121,11 +121,11 @@ Example:: os> source=people | eval `LOWER('helloworld')` = LOWER('helloworld'), `LOWER('HELLOWORLD')` = LOWER('HELLOWORLD') | fields `LOWER('helloworld')`, `LOWER('HELLOWORLD')` fetched rows / total rows = 1/1 - +-----------------------+-----------------------+ - | LOWER('helloworld') | LOWER('HELLOWORLD') | - |-----------------------+-----------------------| - | helloworld | helloworld | - +-----------------------+-----------------------+ + +---------------------+---------------------+ + | LOWER('helloworld') | LOWER('HELLOWORLD') | + |---------------------+---------------------| + | helloworld | helloworld | + +---------------------+---------------------+ LTRIM @@ -144,11 +144,11 @@ Example:: os> source=people | eval `LTRIM(' hello')` = LTRIM(' hello'), `LTRIM('hello ')` = LTRIM('hello ') | fields `LTRIM(' hello')`, `LTRIM('hello ')` fetched rows / total rows = 1/1 - +---------------------+---------------------+ - | LTRIM(' hello') | LTRIM('hello ') | - |---------------------+---------------------| - | hello | hello | - +---------------------+---------------------+ + +-------------------+-------------------+ + | LTRIM(' hello') | LTRIM('hello ') | + |-------------------+-------------------| + | hello | hello | + +-------------------+-------------------+ POSITION @@ -169,11 +169,11 @@ Example:: os> source=people | eval `POSITION('world' IN 'helloworld')` = POSITION('world' IN 'helloworld'), `POSITION('invalid' IN 'helloworld')`= POSITION('invalid' IN 'helloworld') | fields `POSITION('world' IN 'helloworld')`, `POSITION('invalid' IN 'helloworld')` fetched rows / total rows = 1/1 - +-------------------------------------+---------------------------------------+ - | POSITION('world' IN 'helloworld') | POSITION('invalid' IN 'helloworld') | - |-------------------------------------+---------------------------------------| - | 6 | 0 | - +-------------------------------------+---------------------------------------+ + +-----------------------------------+-------------------------------------+ + | POSITION('world' IN 'helloworld') | POSITION('invalid' IN 'helloworld') | + |-----------------------------------+-------------------------------------| + | 6 | 0 | + +-----------------------------------+-------------------------------------+ REVERSE @@ -192,11 +192,11 @@ Example:: os> source=people | eval `REVERSE('abcde')` = REVERSE('abcde') | fields `REVERSE('abcde')` fetched rows / total rows = 1/1 - +--------------------+ - | REVERSE('abcde') | - |--------------------| - | edcba | - +--------------------+ + +------------------+ + | REVERSE('abcde') | + |------------------| + | edcba | + +------------------+ RIGHT @@ -215,11 +215,11 @@ 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 - +--------------------------+--------------------------+ - | RIGHT('helloworld', 5) | RIGHT('HELLOWORLD', 0) | - |--------------------------+--------------------------| - | world | | - +--------------------------+--------------------------+ + +------------------------+------------------------+ + | RIGHT('helloworld', 5) | RIGHT('HELLOWORLD', 0) | + |------------------------+------------------------| + | world | | + +------------------------+------------------------+ RTRIM @@ -238,11 +238,11 @@ Example:: os> source=people | eval `RTRIM(' hello')` = RTRIM(' hello'), `RTRIM('hello ')` = RTRIM('hello ') | fields `RTRIM(' hello')`, `RTRIM('hello ')` fetched rows / total rows = 1/1 - +---------------------+---------------------+ - | RTRIM(' hello') | RTRIM('hello ') | - |---------------------+---------------------| - | hello | hello | - +---------------------+---------------------+ + +-------------------+-------------------+ + | RTRIM(' hello') | RTRIM('hello ') | + |-------------------+-------------------| + | hello | hello | + +-------------------+-------------------+ SUBSTRING @@ -263,11 +263,11 @@ 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 - +------------------------------+---------------------------------+ - | SUBSTRING('helloworld', 5) | SUBSTRING('helloworld', 5, 3) | - |------------------------------+---------------------------------| - | oworld | owo | - +------------------------------+---------------------------------+ + +----------------------------+-------------------------------+ + | SUBSTRING('helloworld', 5) | SUBSTRING('helloworld', 5, 3) | + |----------------------------+-------------------------------| + | oworld | owo | + +----------------------------+-------------------------------+ TRIM @@ -284,11 +284,11 @@ Example:: os> source=people | eval `TRIM(' hello')` = TRIM(' hello'), `TRIM('hello ')` = TRIM('hello ') | fields `TRIM(' hello')`, `TRIM('hello ')` fetched rows / total rows = 1/1 - +--------------------+--------------------+ - | TRIM(' hello') | TRIM('hello ') | - |--------------------+--------------------| - | hello | hello | - +--------------------+--------------------+ + +------------------+------------------+ + | TRIM(' hello') | TRIM('hello ') | + |------------------+------------------| + | hello | hello | + +------------------+------------------+ UPPER @@ -307,8 +307,8 @@ Example:: os> source=people | eval `UPPER('helloworld')` = UPPER('helloworld'), `UPPER('HELLOWORLD')` = UPPER('HELLOWORLD') | fields `UPPER('helloworld')`, `UPPER('HELLOWORLD')` fetched rows / total rows = 1/1 - +-----------------------+-----------------------+ - | UPPER('helloworld') | UPPER('HELLOWORLD') | - |-----------------------+-----------------------| - | HELLOWORLD | HELLOWORLD | - +-----------------------+-----------------------+ + +---------------------+---------------------+ + | UPPER('helloworld') | UPPER('HELLOWORLD') | + |---------------------+---------------------| + | HELLOWORLD | HELLOWORLD | + +---------------------+---------------------+ diff --git a/docs/user/ppl/functions/system.rst b/docs/user/ppl/functions/system.rst index cfe0414c49..698933a3c4 100644 --- a/docs/user/ppl/functions/system.rst +++ b/docs/user/ppl/functions/system.rst @@ -24,8 +24,8 @@ Example:: os> source=people | eval `typeof(date)` = typeof(DATE('2008-04-14')), `typeof(int)` = typeof(1), `typeof(now())` = typeof(now()), `typeof(column)` = typeof(accounts) | fields `typeof(date)`, `typeof(int)`, `typeof(now())`, `typeof(column)` fetched rows / total rows = 1/1 - +----------------+---------------+-----------------+------------------+ - | typeof(date) | typeof(int) | typeof(now()) | typeof(column) | - |----------------+---------------+-----------------+------------------| - | DATE | INTEGER | TIMESTAMP | OBJECT | - +----------------+---------------+-----------------+------------------+ + +--------------+-------------+---------------+----------------+ + | typeof(date) | typeof(int) | typeof(now()) | typeof(column) | + |--------------+-------------+---------------+----------------| + | DATE | INTEGER | TIMESTAMP | OBJECT | + +--------------+-------------+---------------+----------------+ diff --git a/docs/user/ppl/general/datatypes.rst b/docs/user/ppl/general/datatypes.rst index 18555dec3d..a205626dbd 100644 --- a/docs/user/ppl/general/datatypes.rst +++ b/docs/user/ppl/general/datatypes.rst @@ -356,11 +356,11 @@ PPL query:: os> source=people | fields city, city.name, city.location.latitude; fetched rows / total rows = 1/1 - +-----------------------------------------------------+-------------+--------------------------+ - | city | city.name | city.location.latitude | - |-----------------------------------------------------+-------------+--------------------------| - | {'name': 'Seattle', 'location': {'latitude': 10.5}} | Seattle | 10.5 | - +-----------------------------------------------------+-------------+--------------------------+ + +-----------------------------------------------------+-----------+------------------------+ + | city | city.name | city.location.latitude | + |-----------------------------------------------------+-----------+------------------------| + | {'name': 'Seattle', 'location': {'latitude': 10.5}} | Seattle | 10.5 | + +-----------------------------------------------------+-----------+------------------------+ Example 2: Group by struct inner attribute @@ -372,11 +372,11 @@ PPL query:: os> source=people | stats count() by city.name; fetched rows / total rows = 1/1 - +-----------+-------------+ - | count() | city.name | - |-----------+-------------| - | 1 | Seattle | - +-----------+-------------+ + +---------+-----------+ + | count() | city.name | + |---------+-----------| + | 1 | Seattle | + +---------+-----------+ Example 3: Selecting Field of Array Value ----------------------------------------- @@ -385,8 +385,8 @@ Select deeper level for object fields of array value which returns the first ele os> source = people | fields accounts, accounts.id; fetched rows / total rows = 1/1 - +------------+---------------+ - | accounts | accounts.id | - |------------+---------------| - | {'id': 1} | 1 | - +------------+---------------+ \ No newline at end of file + +-----------+-------------+ + | accounts | accounts.id | + |-----------+-------------| + | {'id': 1} | 1 | + +-----------+-------------+ \ No newline at end of file diff --git a/docs/user/ppl/general/identifiers.rst b/docs/user/ppl/general/identifiers.rst index 51fc36c40f..bab540ffdd 100644 --- a/docs/user/ppl/general/identifiers.rst +++ b/docs/user/ppl/general/identifiers.rst @@ -39,14 +39,14 @@ Here are examples for using index pattern directly without quotes:: os> source=accounts | fields account_number, firstname, lastname; fetched rows / total rows = 4/4 - +------------------+-------------+------------+ - | account_number | firstname | lastname | - |------------------+-------------+------------| - | 1 | Amber | Duke | - | 6 | Hattie | Bond | - | 13 | Nanette | Bates | - | 18 | Dale | Adams | - +------------------+-------------+------------+ + +----------------+-----------+----------+ + | account_number | firstname | lastname | + |----------------+-----------+----------| + | 1 | Amber | Duke | + | 6 | Hattie | Bond | + | 13 | Nanette | Bates | + | 18 | Dale | Adams | + +----------------+-----------+----------+ Delimited Identifiers @@ -73,14 +73,14 @@ Here are examples for quoting an index name by back ticks:: os> source=`accounts` | fields `account_number`; fetched rows / total rows = 4/4 - +------------------+ - | account_number | - |------------------| - | 1 | - | 6 | - | 13 | - | 18 | - +------------------+ + +----------------+ + | account_number | + |----------------| + | 1 | + | 6 | + | 13 | + | 18 | + +----------------+ Cross-Cluster Index Identifiers @@ -135,29 +135,29 @@ Query wildcard indices:: os> source=acc* | stats count(); fetched rows / total rows = 1/1 - +-----------+ - | count() | - |-----------| - | 5 | - +-----------+ + +---------+ + | count() | + |---------| + | 5 | + +---------+ Query multiple indices seperated by ``,``:: os> source=accounts, account2 | stats count(); fetched rows / total rows = 1/1 - +-----------+ - | count() | - |-----------| - | 5 | - +-----------+ + +---------+ + | count() | + |---------| + | 5 | + +---------+ Query delimited multiple indices seperated by ``,``:: os> source=`accounts,account2` | stats count(); fetched rows / total rows = 1/1 - +-----------+ - | count() | - |-----------| - | 5 | - +-----------+ + +---------+ + | count() | + |---------| + | 5 | + +---------+ diff --git a/doctest/build.gradle b/doctest/build.gradle index a125a4f336..91d54c9cb2 100644 --- a/doctest/build.gradle +++ b/doctest/build.gradle @@ -22,8 +22,16 @@ def path = project(':').projectDir def plugin_path = project(':doctest').projectDir task cloneSqlCli(type: Exec) { - // clone the sql-cli repo locally - commandLine 'git', 'clone', 'https://github.com/opensearch-project/sql-cli.git' + def repoDir = new File("${project.projectDir}/sql-cli") + + if (repoDir.exists()) { + // Repository already exists, fetch and checkout latest + commandLine 'git', '-C', repoDir.absolutePath, 'fetch', 'origin', 'main' + commandLine 'git', '-C', repoDir.absolutePath, 'checkout', 'origin/main' + } else { + // Repository doesn't exist, clone it + commandLine 'git', 'clone', 'https://github.com/opensearch-project/sql-cli.git', repoDir.absolutePath + } } task bootstrap(type: Exec, dependsOn: ['cloneSqlCli', 'spotlessJava']) { diff --git a/doctest/test_docs.py b/doctest/test_docs.py index 1fedbdf49e..881078a9bd 100644 --- a/doctest/test_docs.py +++ b/doctest/test_docs.py @@ -48,10 +48,34 @@ def process(self, statement): click.echo(output) +""" +For _explain requests, there are several additional request fields that will inconsistently +appear/change depending on underlying cluster state. This method normalizes these responses in-place +to make _explain doctests more consistent. + +If the passed response is not an _explain response, the input is left unmodified. +""" +def normalize_explain_response(data): + if "root" in data: + data = data["root"] + + if (request := data.get("description", {}).get("request", None)) and request.startswith("OpenSearchQueryRequest("): + for filter_field in ["needClean", "pitId", "cursorKeepAlive", "searchAfter", "searchResponse"]: + request = re.sub(f", {filter_field}=\\w+", "", request) + data["description"]["request"] = request + + for child in data.get("children", []): + normalize_explain_response(child) + + return data + + def pretty_print(s): try: - d = json.loads(s) - print(json.dumps(d, indent=2)) + data = json.loads(s) + normalize_explain_response(data) + + print(json.dumps(data, indent=2)) except json.decoder.JSONDecodeError: print(s)