Skip to content

Commit

Permalink
test: add create view test
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed May 12, 2024
1 parent 6421e6c commit 3b8b072
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 0 deletions.
111 changes: 111 additions & 0 deletions tests/cases/standalone/common/view/create.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
--- test CREATE VIEW ---
CREATE DATABASE for_test_view;

Affected Rows: 1

USE for_test_view;

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

CREATE VIEW test_view as SELECT * FROM public.numbers;

Affected Rows: 0

SHOW TABLES;

+-----------+
| Tables |
+-----------+
| test_view |
+-----------+

SHOW FULL TABLES;

+-----------+------------+
| Tables | Table_type |
+-----------+------------+
| test_view | VIEW |
+-----------+------------+

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 | 8 | |
| greptime | information_schema | character_sets | LOCAL TEMPORARY | 9 | |
| greptime | information_schema | check_constraints | LOCAL TEMPORARY | 12 | |
| greptime | information_schema | cluster_info | LOCAL TEMPORARY | 31 | |
| greptime | information_schema | collation_character_set_applicability | LOCAL TEMPORARY | 11 | |
| greptime | information_schema | collations | LOCAL TEMPORARY | 10 | |
| greptime | information_schema | column_privileges | LOCAL TEMPORARY | 6 | |
| greptime | information_schema | column_statistics | LOCAL TEMPORARY | 7 | |
| greptime | information_schema | columns | LOCAL TEMPORARY | 4 | |
| greptime | information_schema | engines | LOCAL TEMPORARY | 5 | |
| greptime | information_schema | events | LOCAL TEMPORARY | 13 | |
| greptime | information_schema | files | LOCAL TEMPORARY | 14 | |
| greptime | information_schema | global_status | LOCAL TEMPORARY | 25 | |
| greptime | information_schema | key_column_usage | LOCAL TEMPORARY | 16 | |
| greptime | public | numbers | LOCAL TEMPORARY | 2 | test_engine |
| greptime | information_schema | optimizer_trace | LOCAL TEMPORARY | 17 | |
| greptime | information_schema | parameters | LOCAL TEMPORARY | 18 | |
| greptime | information_schema | partitions | LOCAL TEMPORARY | 28 | |
| greptime | information_schema | profiling | LOCAL TEMPORARY | 19 | |
| greptime | information_schema | referential_constraints | LOCAL TEMPORARY | 20 | |
| greptime | information_schema | region_peers | LOCAL TEMPORARY | 29 | |
| greptime | information_schema | routines | LOCAL TEMPORARY | 21 | |
| greptime | information_schema | runtime_metrics | LOCAL TEMPORARY | 27 | |
| greptime | information_schema | schema_privileges | LOCAL TEMPORARY | 22 | |
| greptime | information_schema | schemata | LOCAL TEMPORARY | 15 | |
| greptime | information_schema | session_status | LOCAL TEMPORARY | 26 | |
| greptime | information_schema | table_constraints | LOCAL TEMPORARY | 30 | |
| greptime | information_schema | table_privileges | LOCAL TEMPORARY | 23 | |
| greptime | information_schema | tables | LOCAL TEMPORARY | 3 | |
| greptime | for_test_view | test_view | VIEW | 1051 | |
| greptime | information_schema | triggers | LOCAL TEMPORARY | 24 | |
+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+

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 | 1051 | |
+---------------+---------------+------------+------------+----------+--------+

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

32 changes: 32 additions & 0 deletions tests/cases/standalone/common/view/create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--- test CREATE VIEW ---

CREATE DATABASE for_test_view;

USE for_test_view;

CREATE VIEW test_view;

CREATE VIEW test_view as DELETE FROM public.numbers;

CREATE VIEW test_view as SELECT * FROM public.numbers;

SHOW TABLES;

SHOW FULL TABLES;

SELECT * FROM INFORMATION_SCHEMA.TABLES ORDER BY TABLE_NAME, TABLE_TYPE;

SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'VIEW';

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;

USE public;

DROP DATABASE for_test_view;

0 comments on commit 3b8b072

Please sign in to comment.