ClickHouse/tests/queries/0_stateless/02706_show_columns.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
1.8 KiB
MySQL
Raw Normal View History

-- Tags: no-parallel
-- no-parallel: creates a custom database schema and expects to use it exclusively
-- Create a test table and verify that the output of SHOW COLUMNS is sane.
-- The matching of actual/expected results relies on the fact that the output of SHOW COLUMNS is sorted.
2023-03-29 09:39:58 +00:00
DROP TABLE IF EXISTS tab;
CREATE TABLE tab
(
`uint64` UInt64,
`int32` Nullable(Int32) COMMENT 'example comment',
`str` String,
INDEX idx str TYPE set(1000)
)
ENGINE = MergeTree
PRIMARY KEY (uint64)
ORDER BY (uint64, str);
SHOW COLUMNS FROM tab;
2023-03-31 09:41:59 +00:00
SELECT '--- EXTENDED';
SHOW EXTENDED COLUMNS FROM tab;
2023-03-31 09:41:59 +00:00
SELECT '--- FULL';
SHOW FULL COLUMNS FROM tab;
2023-03-31 09:41:59 +00:00
SELECT '--- LIKE';
SHOW COLUMNS FROM tab LIKE '%int%';
2023-03-31 09:41:59 +00:00
SELECT '--- NOT LIKE';
SHOW COLUMNS FROM tab NOT LIKE '%int%';
2023-03-31 09:41:59 +00:00
SELECT '--- ILIKE';
SHOW COLUMNS FROM tab ILIKE '%INT%';
2023-03-31 09:41:59 +00:00
SELECT '--- NOT ILIKE';
SHOW COLUMNS FROM tab NOT ILIKE '%INT%';
2023-03-31 09:41:59 +00:00
SELECT '--- WHERE';
SHOW COLUMNS FROM tab WHERE field LIKE '%int%';
2023-03-31 09:41:59 +00:00
SELECT '--- LIMIT';
SHOW COLUMNS FROM tab LIMIT 1;
-- Create a table in a different database. Intentionally useing the same table/column names as above so
-- we notice if something is buggy in the implementation of SHOW COLUMNS.
2023-03-28 20:03:55 +00:00
DROP DATABASE IF EXISTS database_123456789abcde;
CREATE DATABASE database_123456789abcde; -- pseudo-random database name
2023-03-29 09:39:58 +00:00
DROP TABLE IF EXISTS database_123456789abcde.tab;
CREATE TABLE database_123456789abcde.tab
(
`uint64` UInt64,
`int32` Int32,
`str` String
)
ENGINE = MergeTree
ORDER BY uint64;
2023-03-31 09:41:59 +00:00
SELECT '--- Original table';
SHOW COLUMNS FROM tab;
2023-03-31 09:41:59 +00:00
SELECT '--- Equally named table in other database';
SHOW COLUMNS FROM tab FROM database_123456789abcde;
2023-03-31 09:41:59 +00:00
SELECT '--- Short form';
SHOW COLUMNS FROM database_123456789abcde.tab;
2023-03-28 20:03:55 +00:00
DROP DATABASE database_123456789abcde;
DROP TABLE tab;