Files
greptimedb/tests/cases/standalone/common/view/create.sql
dennis zhuang efd3f04b7c feat: create view (#3807)
* 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>
2024-05-14 08:03:29 +00:00

53 lines
1.3 KiB
SQL

--- test CREATE VIEW ---
CREATE DATABASE for_test_view;
USE for_test_view;
CREATE TABLE test_table(a STRING, ts TIMESTAMP TIME INDEX);
CREATE VIEW test_view;
CREATE VIEW test_view as DELETE FROM public.numbers;
--- Table already exists ---
CREATE VIEW test_table as SELECT * FROM public.numbers;
--- Table already exists even when create_if_not_exists ---
CREATE VIEW IF NOT EXISTS test_table as SELECT * FROM public.numbers;
--- Table already exists even when or_replace ---
CREATE OR REPLACE VIEW test_table as SELECT * FROM public.numbers;
CREATE VIEW test_view as SELECT * FROM public.numbers;
--- View already exists ----
CREATE VIEW test_view as SELECT * FROM public.numbers;
CREATE VIEW IF NOT EXISTS test_view as SELECT * FROM public.numbers;
CREATE OR REPLACE VIEW test_view as SELECT * FROM public.numbers;
SHOW TABLES;
SHOW FULL TABLES;
-- SQLNESS REPLACE (\s\d+\s) ID
SELECT * FROM INFORMATION_SCHEMA.TABLES ORDER BY TABLE_NAME, TABLE_TYPE;
-- SQLNESS REPLACE (\s\d+\s) ID
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;