Skip to content

Commit

Permalink
test: adds more sqlness test for view
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed May 21, 2024
1 parent 55b1545 commit 2669c3f
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/cases/standalone/common/view/view.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
-- From: https://github.com/duckdb/duckdb/blob/main/test/sql/catalog/view/test_view.test --
CREATE DATABASE schema_for_view_test;

Affected Rows: 1

USE schema_for_view_test;

Affected Rows: 0

CREATE TABLE t1(i TIMESTAMP TIME INDEX);

Affected Rows: 0

INSERT INTO t1 VALUES (41), (42), (43);

Affected Rows: 3

CREATE VIEW v1 AS SELECT
i AS j
FROM t1 WHERE i < 43;

Affected Rows: 0

SELECT * FROM v1;

+-------------------------+
| i |
+-------------------------+
| 1970-01-01T00:00:00.041 |
| 1970-01-01T00:00:00.042 |
+-------------------------+

-- CREATE VIEW v1 AS SELECT 'whatever'; --
SELECT j FROM v1 WHERE j > 41;

Error: 3000(PlanQuery), Failed to plan SQL: No field named j. Valid fields are v1.i.

-- FIXME(dennis):: name alias in view, not supported yet --
--SELECT x FROM v1 t1(x) WHERE x > 41 --
-- FIXME(dennis): DROP VIEW not supported yet--
-- DROP VIEW v1 --
-- SELECT j FROM v1 WHERE j > 41 --
-- CREATE VIEW v1 AS SELECT 'whatever'; --
-- SELECT * FROM v1; --
-- CREATE OR REPLACE VIEW v1 AS SELECT 42; --
-- SELECT * FROM v1; --
INSERT INTO v1 VALUES (1);

Error: 1004(InvalidArguments), Invalid SQL, error: column count mismatch, columns: 0, values: 1

CREATE VIEW v1 AS SELECT * FROM dontexist;

Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Table not found: greptime.schema_for_view_test.dontexist

USE public;

Affected Rows: 0

DROP DATABASE schema_for_view_test;

Affected Rows: 0

45 changes: 45 additions & 0 deletions tests/cases/standalone/common/view/view.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-- From: https://github.com/duckdb/duckdb/blob/main/test/sql/catalog/view/test_view.test --

CREATE DATABASE schema_for_view_test;

USE schema_for_view_test;

CREATE TABLE t1(i TIMESTAMP TIME INDEX);

INSERT INTO t1 VALUES (41), (42), (43);

CREATE VIEW v1 AS SELECT
i AS j
FROM t1 WHERE i < 43;

SELECT * FROM v1;

-- CREATE VIEW v1 AS SELECT 'whatever'; --

SELECT j FROM v1 WHERE j > 41;


-- FIXME(dennis):: name alias in view, not supported yet --
--SELECT x FROM v1 t1(x) WHERE x > 41 --

-- FIXME(dennis): DROP VIEW not supported yet--
-- DROP VIEW v1 --

-- SELECT j FROM v1 WHERE j > 41 --

-- CREATE VIEW v1 AS SELECT 'whatever'; --

-- SELECT * FROM v1; --


-- CREATE OR REPLACE VIEW v1 AS SELECT 42; --

-- SELECT * FROM v1; --

INSERT INTO v1 VALUES (1);

CREATE VIEW v1 AS SELECT * FROM dontexist;

USE public;

DROP DATABASE schema_for_view_test;

0 comments on commit 2669c3f

Please sign in to comment.