2023-03-26 14:36:38 +00:00
|
|
|
-- 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
|
2023-03-26 14:36:38 +00:00
|
|
|
(
|
|
|
|
`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);
|
|
|
|
|
2023-04-26 09:46:35 +00:00
|
|
|
SELECT '--- Aliases of SHOW COLUMNS';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM tab;
|
2023-04-26 09:46:35 +00:00
|
|
|
SHOW FIELDS FROM tab;
|
2023-03-26 14:36:38 +00:00
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- EXTENDED';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW EXTENDED COLUMNS FROM tab;
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- FULL';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW FULL COLUMNS FROM tab;
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- LIKE';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM tab LIKE '%int%';
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- NOT LIKE';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM tab NOT LIKE '%int%';
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- ILIKE';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM tab ILIKE '%INT%';
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- NOT ILIKE';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM tab NOT ILIKE '%INT%';
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- WHERE';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM tab WHERE field LIKE '%int%';
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- LIMIT';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM tab LIMIT 1;
|
|
|
|
|
2023-05-05 11:03:47 +00:00
|
|
|
SELECT '--- Check with weird table names';
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS `$4@^7`;
|
|
|
|
CREATE TABLE `$4@^7` (c String) ENGINE = MergeTree ORDER BY c;
|
|
|
|
SHOW COLUMNS FROM `$4@^7`;
|
|
|
|
DROP TABLE `$4@^7`;
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS NULL;
|
|
|
|
CREATE TABLE NULL (c String) ENGINE = MergeTree ORDER BY c;
|
|
|
|
SHOW COLUMNS FROM NULL;
|
|
|
|
DROP TABLE NULL;
|
|
|
|
|
|
|
|
DROP DATABASE IF EXISTS `'`;
|
|
|
|
CREATE DATABASE `'`;
|
|
|
|
CREATE TABLE `'`.`'` (c String) ENGINE = MergeTree ORDER BY c;
|
|
|
|
SHOW COLUMNS FROM `'` FROM `'`;
|
|
|
|
SHOW COLUMNS FROM `'`.`'`; -- abbreviated form
|
|
|
|
DROP TABLE `'`.`'`;
|
|
|
|
DROP DATABASE `'`;
|
|
|
|
|
2023-03-26 14:36:38 +00:00
|
|
|
-- 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;
|
2023-03-26 14:36:38 +00:00
|
|
|
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
|
2023-03-26 14:36:38 +00:00
|
|
|
(
|
|
|
|
`uint64` UInt64,
|
|
|
|
`int32` Int32,
|
|
|
|
`str` String
|
|
|
|
)
|
|
|
|
ENGINE = MergeTree
|
|
|
|
ORDER BY uint64;
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- Original table';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM tab;
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- Equally named table in other database';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM tab FROM database_123456789abcde;
|
|
|
|
|
2023-03-31 09:41:59 +00:00
|
|
|
SELECT '--- Short form';
|
2023-03-26 14:36:38 +00:00
|
|
|
SHOW COLUMNS FROM database_123456789abcde.tab;
|
|
|
|
|
2023-03-28 20:03:55 +00:00
|
|
|
DROP DATABASE database_123456789abcde;
|
2023-03-26 14:36:38 +00:00
|
|
|
|
|
|
|
DROP TABLE tab;
|