mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-15 17:52:57 +00:00
* add statement Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * feat: rebase with main * fix: create flow * feat: adds gRPC stuff * feat: impl create_view ddl in operator * feat: impl CreateViewProcedure * chore: update cargo lock * fix: format * chore: compile error after rebasing main * chore: refactor and test create view parser * chore: fixed todo list and comments * fix: compile error after rebeasing * test: add create view test * test: test view_info keys * test: adds test for CreateViewProcedure and clean code * test: adds more sqlness test for creating views * chore: update cargo lock * fix: don't replace normal table in CreateViewProcedure * chore: apply suggestion Co-authored-by: Jeremyhi <jiachun_feng@proton.me> * chore: style Co-authored-by: Jeremyhi <jiachun_feng@proton.me> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: Jeremyhi <jiachun_feng@proton.me>
149 lines
7.0 KiB
Plaintext
149 lines
7.0 KiB
Plaintext
--- test CREATE VIEW ---
|
|
CREATE DATABASE for_test_view;
|
|
|
|
Affected Rows: 1
|
|
|
|
USE for_test_view;
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE test_table(a STRING, ts TIMESTAMP TIME INDEX);
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE VIEW test_view;
|
|
|
|
Error: 2000(InvalidSyntax), sql parser error: Expected AS, found: ; at Line: 1, Column 22
|
|
|
|
CREATE VIEW test_view as DELETE FROM public.numbers;
|
|
|
|
Error: 2000(InvalidSyntax), sql parser error: Expected SELECT, VALUES, or a subquery in the query body, found: DELETE at Line: 1, Column 26
|
|
|
|
--- Table already exists ---
|
|
CREATE VIEW test_table as SELECT * FROM public.numbers;
|
|
|
|
Error: 4000(TableAlreadyExists), Table already exists: `greptime.for_test_view.test_table`
|
|
|
|
--- Table already exists even when create_if_not_exists ---
|
|
CREATE VIEW IF NOT EXISTS test_table as SELECT * FROM public.numbers;
|
|
|
|
Error: 4000(TableAlreadyExists), Table already exists: `greptime.for_test_view.test_table`
|
|
|
|
--- Table already exists even when or_replace ---
|
|
CREATE OR REPLACE VIEW test_table as SELECT * FROM public.numbers;
|
|
|
|
Error: 4000(TableAlreadyExists), Table already exists: `greptime.for_test_view.test_table`
|
|
|
|
CREATE VIEW test_view as SELECT * FROM public.numbers;
|
|
|
|
Affected Rows: 0
|
|
|
|
--- View already exists ----
|
|
CREATE VIEW test_view as SELECT * FROM public.numbers;
|
|
|
|
Error: 4000(TableAlreadyExists), View already exists: `greptime.for_test_view.test_view`
|
|
|
|
CREATE VIEW IF NOT EXISTS test_view as SELECT * FROM public.numbers;
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE OR REPLACE VIEW test_view as SELECT * FROM public.numbers;
|
|
|
|
Affected Rows: 0
|
|
|
|
SHOW TABLES;
|
|
|
|
+------------+
|
|
| Tables |
|
|
+------------+
|
|
| test_table |
|
|
| test_view |
|
|
+------------+
|
|
|
|
SHOW FULL TABLES;
|
|
|
|
+------------+------------+
|
|
| Tables | Table_type |
|
|
+------------+------------+
|
|
| test_table | BASE TABLE |
|
|
| test_view | VIEW |
|
|
+------------+------------+
|
|
|
|
-- SQLNESS REPLACE (\s\d+\s) ID
|
|
SELECT * FROM INFORMATION_SCHEMA.TABLES ORDER BY TABLE_NAME, TABLE_TYPE;
|
|
|
|
+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+
|
|
| table_catalog | table_schema | table_name | table_type | table_id | engine |
|
|
+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+
|
|
| greptime | information_schema | build_info | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | character_sets | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | check_constraints | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | cluster_info | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | collation_character_set_applicability | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | collations | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | column_privileges | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | column_statistics | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | columns | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | engines | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | events | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | files | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | global_status | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | key_column_usage | LOCAL TEMPORARY |ID | |
|
|
| greptime | public | numbers | LOCAL TEMPORARY |ID | test_engine |
|
|
| greptime | information_schema | optimizer_trace | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | parameters | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | partitions | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | profiling | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | referential_constraints | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | region_peers | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | routines | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | runtime_metrics | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | schema_privileges | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | schemata | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | session_status | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | table_constraints | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | table_privileges | LOCAL TEMPORARY |ID | |
|
|
| greptime | information_schema | tables | LOCAL TEMPORARY |ID | |
|
|
| greptime | for_test_view | test_table | BASE TABLE |ID | mito |
|
|
| greptime | for_test_view | test_view | VIEW |ID | |
|
|
| greptime | information_schema | triggers | LOCAL TEMPORARY |ID | |
|
|
+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+
|
|
|
|
-- SQLNESS REPLACE (\s\d+\s) ID
|
|
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'VIEW';
|
|
|
|
+---------------+---------------+------------+------------+----------+--------+
|
|
| table_catalog | table_schema | table_name | table_type | table_id | engine |
|
|
+---------------+---------------+------------+------------+----------+--------+
|
|
| greptime | for_test_view | test_view | VIEW |ID | |
|
|
+---------------+---------------+------------+------------+----------+--------+
|
|
|
|
SHOW COLUMNS FROM test_view;
|
|
|
|
++
|
|
++
|
|
|
|
SHOW FULL COLUMNS FROM test_view;
|
|
|
|
++
|
|
++
|
|
|
|
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'test_view';
|
|
|
|
++
|
|
++
|
|
|
|
--- FIXED in the following PR ---
|
|
SELECT * FROM test_view;
|
|
|
|
Error: 3001(EngineExecuteQuery), DataFusion error: Unsupported operation: get stream from a distributed table
|
|
|
|
USE public;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP DATABASE for_test_view;
|
|
|
|
Affected Rows: 0
|
|
|