mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-15 01:32:56 +00:00
* feat: querying from view works * feat: use MemoryCatalogProviderList instead of DummyCatalogList * refactor: revert src/query/src/dummy_catalog.rs * chore: clean code * fix: make clippy happy * fix: toml format * fix: sqlness * fix: forgot files * fix: make sqlness happy * test: table source, serializer and decoder * fix: fail to decode plan because of invalid table names * test: adds more sqlness test for view * chore: remove unused errors * fix: comments * fix: typo * fix: invalidate view info cache after creating view successfully * chore: apply suggestion Co-authored-by: Ruihang Xia <waynestxia@gmail.com> * chore: apply suggestion Co-authored-by: Ruihang Xia <waynestxia@gmail.com> * fix: compile error after rebeasing * chore: style Co-authored-by: Ruihang Xia <waynestxia@gmail.com> * fix: don't export table_name in common-meta * chore: change ViewInfo::new signature * docs: leave a TODO for optimize param --------- Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
161 lines
7.2 KiB
Plaintext
161 lines
7.2 KiB
Plaintext
--- test CREATE VIEW ---
|
|
CREATE DATABASE schema_for_view_test;
|
|
|
|
Affected Rows: 1
|
|
|
|
USE schema_for_view_test;
|
|
|
|
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.schema_for_view_test.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.schema_for_view_test.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.schema_for_view_test.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.schema_for_view_test.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 | schema_for_view_test | test_table | BASE TABLE |ID | mito |
|
|
| greptime | schema_for_view_test | 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 | schema_for_view_test | 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';
|
|
|
|
++
|
|
++
|
|
|
|
SELECT * FROM test_view LIMIT 10;
|
|
|
|
+--------+
|
|
| number |
|
|
+--------+
|
|
| 0 |
|
|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
+--------+
|
|
|
|
USE public;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP DATABASE schema_for_view_test;
|
|
|
|
Affected Rows: 0
|
|
|