Files
greptimedb/tests/cases/standalone/common/function/function_alias.result
dennis zhuang 2dfcf35fee feat: support function aliases and add MySQL-compatible aliases (#7410)
* feat: support function aliases and add MySQL-compatible aliases

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix: get_table_function_source

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* refactor: add function_alias mod

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix: license

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2025-12-16 06:56:23 +00:00

73 lines
2.1 KiB
Plaintext

-- MySQL-compatible function alias tests
-- ucase -> upper
SELECT
ucase('dataFusion') AS ucase_value,
upper('dataFusion') AS upper_value;
+-------------+-------------+
| ucase_value | upper_value |
+-------------+-------------+
| DATAFUSION | DATAFUSION |
+-------------+-------------+
-- lcase -> lower
SELECT
lcase('DataFusion') AS lcase_value,
lower('DataFusion') AS lower_value;
+-------------+-------------+
| lcase_value | lower_value |
+-------------+-------------+
| datafusion | datafusion |
+-------------+-------------+
-- ceiling -> ceil
SELECT
ceiling(1.2) AS ceiling_pos,
ceil(1.2) AS ceil_pos,
ceiling(-1.2) AS ceiling_neg,
ceil(-1.2) AS ceil_neg;
+-------------+----------+-------------+----------+
| ceiling_pos | ceil_pos | ceiling_neg | ceil_neg |
+-------------+----------+-------------+----------+
| 2.0 | 2.0 | -1.0 | -1.0 |
+-------------+----------+-------------+----------+
-- mid -> substr
SELECT
mid('datafusion', 5, 3) AS mid_value,
substr('datafusion', 5, 3) AS substr_value;
+-----------+--------------+
| mid_value | substr_value |
+-----------+--------------+
| fus | fus |
+-----------+--------------+
-- rand -> random
-- NOTE: RAND([seed]) is supported by MySQL, but seed is not supported here.
-- This test only validates that rand() exists and returns values in [0, 1).
SELECT rand() >= 0.0 AND rand() < 1.0 AS rand_in_range;
+---------------+
| rand_in_range |
+---------------+
| true |
+---------------+
-- std -> stddev_pop, variance -> var_pop
SELECT
round(std(x), 6) AS std_value,
round(stddev_pop(x), 6) AS stddev_pop_value,
round(variance(x), 6) AS variance_value,
round(var_pop(x), 6) AS var_pop_value
FROM (VALUES (1.0), (2.0), (3.0)) AS t(x);
+-----------+------------------+----------------+---------------+
| std_value | stddev_pop_value | variance_value | var_pop_value |
+-----------+------------------+----------------+---------------+
| 0.816497 | 0.816497 | 0.666667 | 0.666667 |
+-----------+------------------+----------------+---------------+