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.

98 lines
2.5 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);
2023-04-26 09:46:35 +00:00
SELECT '--- Aliases of SHOW COLUMNS';
SHOW COLUMNS FROM tab;
2023-04-26 09:46:35 +00:00
SHOW FIELDS 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;
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;
2024-09-16 10:48:01 +00:00
DROP TABLE IF EXISTS `tab.with.dots`;
2024-09-16 11:53:47 +00:00
CREATE TABLE `tab.with.dots` (c String) ENGINE = MergeTree ORDER BY c;
2024-09-16 10:48:01 +00:00
SHOW COLUMNS FROM `tab.with.dots`;
DROP TABLE `tab.with.dots`;
2023-05-05 11:03:47 +00:00
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 `'`;
-- 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;