mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-08 22:32:55 +00:00
* feat(mysql): add SHOW WARNINGS support and return warnings for unsupported SET variables Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(function): add MySQL IF() function and PostgreSQL description functions for connector compatibility Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix: show tables for mysql Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix: partitions table in information_schema and add starrocks external catalog compatibility Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor: async udf Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix: set warnings Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat: impl pg_my_temp_schema and make description functions simple Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test: add test for issue 7313 Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat: apply suggestions Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix: partition_expression and partition_description Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix: test Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix: unit tests Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix: saerch_path only works for pg Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat: improve warnings processing Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix: warnings while writing affected rows and refactor Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * chore: improve ShobjDescriptionFunction signature Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor: array_to_boolean Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
230 lines
5.6 KiB
Plaintext
230 lines
5.6 KiB
Plaintext
CREATE TABLE t(a INTEGER, ts timestamp time index);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO t VALUES (1, 1), (null, 2), (3, 3);
|
|
|
|
Affected Rows: 3
|
|
|
|
SELECT ISNULL(a) from t;
|
|
|
|
+-------------+
|
|
| isnull(t.a) |
|
|
+-------------+
|
|
| false |
|
|
| true |
|
|
| false |
|
|
+-------------+
|
|
|
|
SELECT ISNULL(null);
|
|
|
|
+--------------+
|
|
| isnull(NULL) |
|
|
+--------------+
|
|
| true |
|
|
+--------------+
|
|
|
|
SELECT ISNULL(1);
|
|
|
|
+------------------+
|
|
| isnull(Int64(1)) |
|
|
+------------------+
|
|
| false |
|
|
+------------------+
|
|
|
|
SELECT ISNULL(-1);
|
|
|
|
+-------------------+
|
|
| isnull(Int64(-1)) |
|
|
+-------------------+
|
|
| false |
|
|
+-------------------+
|
|
|
|
SELECT ISNULL(1.0);
|
|
|
|
+--------------------+
|
|
| isnull(Float64(1)) |
|
|
+--------------------+
|
|
| false |
|
|
+--------------------+
|
|
|
|
SELECT ISNULL(true);
|
|
|
|
+-----------------------+
|
|
| isnull(Boolean(true)) |
|
|
+-----------------------+
|
|
| false |
|
|
+-----------------------+
|
|
|
|
SELECT ISNULL('string');
|
|
|
|
+------------------------+
|
|
| isnull(Utf8("string")) |
|
|
+------------------------+
|
|
| false |
|
|
+------------------------+
|
|
|
|
SELECT FIRST_VALUE(1);
|
|
|
|
+-----------------------+
|
|
| first_value(Int64(1)) |
|
|
+-----------------------+
|
|
| 1 |
|
|
+-----------------------+
|
|
|
|
SELECT FIRST_VALUE('a');
|
|
|
|
+------------------------+
|
|
| first_value(Utf8("a")) |
|
|
+------------------------+
|
|
| a |
|
|
+------------------------+
|
|
|
|
SELECT LAST_VALUE(1);
|
|
|
|
+----------------------+
|
|
| last_value(Int64(1)) |
|
|
+----------------------+
|
|
| 1 |
|
|
+----------------------+
|
|
|
|
SELECT LAST_VALUE('a');
|
|
|
|
+-----------------------+
|
|
| last_value(Utf8("a")) |
|
|
+-----------------------+
|
|
| a |
|
|
+-----------------------+
|
|
|
|
-- MySQL-compatible IF function tests
|
|
SELECT IF(true, 'yes', 'no');
|
|
|
|
+------------------------------------------+
|
|
| if(Boolean(true),Utf8("yes"),Utf8("no")) |
|
|
+------------------------------------------+
|
|
| yes |
|
|
+------------------------------------------+
|
|
|
|
SELECT IF(false, 'yes', 'no');
|
|
|
|
+-------------------------------------------+
|
|
| if(Boolean(false),Utf8("yes"),Utf8("no")) |
|
|
+-------------------------------------------+
|
|
| no |
|
|
+-------------------------------------------+
|
|
|
|
SELECT IF(NULL, 'yes', 'no');
|
|
|
|
+---------------------------------+
|
|
| if(NULL,Utf8("yes"),Utf8("no")) |
|
|
+---------------------------------+
|
|
| no |
|
|
+---------------------------------+
|
|
|
|
SELECT IF(1, 'yes', 'no');
|
|
|
|
+-------------------------------------+
|
|
| if(Int64(1),Utf8("yes"),Utf8("no")) |
|
|
+-------------------------------------+
|
|
| yes |
|
|
+-------------------------------------+
|
|
|
|
SELECT IF(0, 'yes', 'no');
|
|
|
|
+-------------------------------------+
|
|
| if(Int64(0),Utf8("yes"),Utf8("no")) |
|
|
+-------------------------------------+
|
|
| no |
|
|
+-------------------------------------+
|
|
|
|
SELECT IF(-1, 'yes', 'no');
|
|
|
|
+--------------------------------------+
|
|
| if(Int64(-1),Utf8("yes"),Utf8("no")) |
|
|
+--------------------------------------+
|
|
| yes |
|
|
+--------------------------------------+
|
|
|
|
SELECT IF(1.5, 'yes', 'no');
|
|
|
|
+-----------------------------------------+
|
|
| if(Float64(1.5),Utf8("yes"),Utf8("no")) |
|
|
+-----------------------------------------+
|
|
| yes |
|
|
+-----------------------------------------+
|
|
|
|
SELECT IF(0.0, 'yes', 'no');
|
|
|
|
+---------------------------------------+
|
|
| if(Float64(0),Utf8("yes"),Utf8("no")) |
|
|
+---------------------------------------+
|
|
| no |
|
|
+---------------------------------------+
|
|
|
|
-- Test with table column
|
|
SELECT IF(a > 1, 'greater', 'not greater') FROM t;
|
|
|
|
+--------------------------------------------------------+
|
|
| if(t.a > Int64(1),Utf8("greater"),Utf8("not greater")) |
|
|
+--------------------------------------------------------+
|
|
| not greater |
|
|
| not greater |
|
|
| greater |
|
|
+--------------------------------------------------------+
|
|
|
|
-- Test numeric return types
|
|
SELECT IF(true, 100, 200);
|
|
|
|
+-----------------------------------------+
|
|
| if(Boolean(true),Int64(100),Int64(200)) |
|
|
+-----------------------------------------+
|
|
| 100 |
|
|
+-----------------------------------------+
|
|
|
|
SELECT IF(false, 100, 200);
|
|
|
|
+------------------------------------------+
|
|
| if(Boolean(false),Int64(100),Int64(200)) |
|
|
+------------------------------------------+
|
|
| 200 |
|
|
+------------------------------------------+
|
|
|
|
-- Test with IFNULL (should already work via DataFusion)
|
|
SELECT IFNULL(NULL, 'default');
|
|
|
|
+------------------------------+
|
|
| ifnull(NULL,Utf8("default")) |
|
|
+------------------------------+
|
|
| default |
|
|
+------------------------------+
|
|
|
|
SELECT IFNULL('value', 'default');
|
|
|
|
+---------------------------------------+
|
|
| ifnull(Utf8("value"),Utf8("default")) |
|
|
+---------------------------------------+
|
|
| value |
|
|
+---------------------------------------+
|
|
|
|
-- Test COALESCE (should already work via DataFusion)
|
|
SELECT COALESCE(NULL, NULL, 'third');
|
|
|
|
+-----------------------------------+
|
|
| coalesce(NULL,NULL,Utf8("third")) |
|
|
+-----------------------------------+
|
|
| third |
|
|
+-----------------------------------+
|
|
|
|
SELECT COALESCE('first', 'second');
|
|
|
|
+----------------------------------------+
|
|
| coalesce(Utf8("first"),Utf8("second")) |
|
|
+----------------------------------------+
|
|
| first |
|
|
+----------------------------------------+
|
|
|
|
DROP TABLE t;
|
|
|
|
Affected Rows: 0
|
|
|