ClickHouse/tests/queries/0_stateless/02339_analyzer_matcher_basic.sql

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

187 lines
4.8 KiB
MySQL
Raw Normal View History

2022-09-10 20:06:41 +00:00
-- Tags: no-parallel
SET allow_experimental_analyzer = 1;
2022-07-14 11:31:58 +00:00
SELECT 'Matchers without FROM section';
DESCRIBE (SELECT *);
SELECT *;
SELECT '--';
DESCRIBE (SELECT COLUMNS(dummy));
SELECT COLUMNS(dummy);
SELECT '--';
DESCRIBE (SELECT COLUMNS('d'));
SELECT COLUMNS('d');
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table
(
id UInt64,
value String
) ENGINE=TinyLog;
INSERT INTO test_table VALUES (0, 'Value');
SELECT 'Unqualified matchers';
DESCRIBE (SELECT * FROM test_table);
SELECT * FROM test_table;
SELECT '--';
DESCRIBE (SELECT COLUMNS(id) FROM test_table);
SELECT COLUMNS(id) FROM test_table;
SELECT '--';
DESCRIBE (SELECT COLUMNS(id), COLUMNS(value) FROM test_table);
SELECT COLUMNS(id), COLUMNS(value) FROM test_table;
SELECT '--';
DESCRIBE (SELECT COLUMNS('i'), COLUMNS('v') FROM test_table);
SELECT COLUMNS('i'), COLUMNS('v') FROM test_table;
SELECT 'Table qualified matchers';
DESCRIBE (SELECT test_table.* FROM test_table);
SELECT test_table.* FROM test_table;
SELECT '--';
DESCRIBE (SELECT test_table.COLUMNS(id) FROM test_table);
SELECT test_table.COLUMNS(id) FROM test_table;
SELECT '--';
DESCRIBE (SELECT test_table.COLUMNS(id), test_table.COLUMNS(value) FROM test_table);
SELECT test_table.COLUMNS(id), test_table.COLUMNS(value) FROM test_table;
SELECT '--';
DESCRIBE (SELECT test_table.COLUMNS('i'), test_table.COLUMNS('v') FROM test_table);
SELECT test_table.COLUMNS('i'), test_table.COLUMNS('v') FROM test_table;
SELECT 'Database and table qualified matchers';
DROP DATABASE IF EXISTS 02339_db;
CREATE DATABASE 02339_db;
DROP TABLE IF EXISTS 02339_db.test_table;
CREATE TABLE 02339_db.test_table
(
id UInt64,
value String
) ENGINE=TinyLog;
INSERT INTO 02339_db.test_table VALUES (0, 'Value');
2023-02-24 12:46:09 +00:00
SELECT '--';
2022-07-14 11:31:58 +00:00
2023-02-24 12:46:09 +00:00
DESCRIBE (SELECT 02339_db.test_table.* FROM 02339_db.test_table);
SELECT 02339_db.test_table.* FROM 02339_db.test_table;
2022-07-14 11:31:58 +00:00
2023-02-24 12:46:09 +00:00
SELECT '--';
2022-07-14 11:31:58 +00:00
2023-02-24 12:46:09 +00:00
DESCRIBE (SELECT 02339_db.test_table.COLUMNS(id) FROM 02339_db.test_table);
SELECT 02339_db.test_table.COLUMNS(id) FROM 02339_db.test_table;
2022-07-14 11:31:58 +00:00
2023-02-24 12:46:09 +00:00
SELECT '--';
2022-07-14 11:31:58 +00:00
2023-02-24 12:46:09 +00:00
DESCRIBE (SELECT 02339_db.test_table.COLUMNS(id), 02339_db.test_table.COLUMNS(value) FROM 02339_db.test_table);
SELECT 02339_db.test_table.COLUMNS(id), 02339_db.test_table.COLUMNS(value) FROM 02339_db.test_table;
2022-07-14 11:31:58 +00:00
2023-02-24 12:46:09 +00:00
SELECT '--';
2022-07-14 11:31:58 +00:00
2023-02-24 12:46:09 +00:00
DESCRIBE (SELECT 02339_db.test_table.COLUMNS('i'), 02339_db.test_table.COLUMNS('v') FROM 02339_db.test_table);
SELECT 02339_db.test_table.COLUMNS('i'), 02339_db.test_table.COLUMNS('v') FROM 02339_db.test_table;
2022-07-14 11:31:58 +00:00
DROP TABLE 02339_db.test_table;
DROP DATABASE 02339_db;
SELECT 'APPLY transformer';
SELECT '--';
DESCRIBE (SELECT * APPLY toString FROM test_table);
SELECT * APPLY toString FROM test_table;
SELECT '--';
DESCRIBE (SELECT * APPLY (x -> toString(x)) FROM test_table);
SELECT * APPLY (x -> toString(x)) FROM test_table;
SELECT '--';
DESCRIBE (SELECT * APPLY (x -> toString(x)) APPLY (x -> length(x)) FROM test_table);
SELECT * APPLY (x -> toString(x)) APPLY (x -> length(x)) FROM test_table;
SELECT '--';
DESCRIBE (SELECT * APPLY (x -> toString(x)) APPLY length FROM test_table);
SELECT * APPLY (x -> toString(x)) APPLY length FROM test_table;
SELECT '--';
DESCRIBE (SELECT * FROM test_table);
SELECT * FROM test_table;
SELECT 'EXCEPT transformer';
SELECT '--';
DESCRIBE (SELECT * EXCEPT (id) FROM test_table);
SELECT * EXCEPT (id) FROM test_table;
SELECT '--';
DESCRIBE (SELECT COLUMNS(id, value) EXCEPT (id) FROM test_table);
SELECT COLUMNS(id, value) EXCEPT (id) FROM test_table;
SELECT '--';
DESCRIBE (SELECT * EXCEPT (id) APPLY toString FROM test_table);
SELECT * EXCEPT (id) APPLY toString FROM test_table;
SELECT '--';
DESCRIBE (SELECT COLUMNS(id, value) EXCEPT (id) APPLY toString FROM test_table);
SELECT COLUMNS(id, value) EXCEPT (id) APPLY toString FROM test_table;
SELECT 'REPLACE transformer';
SELECT '--';
DESCRIBE (SELECT * REPLACE (5 AS id) FROM test_table);
SELECT * REPLACE (5 AS id) FROM test_table;
SELECT '--';
DESCRIBE (SELECT COLUMNS(id, value) REPLACE (5 AS id) FROM test_table);
SELECT COLUMNS(id, value) REPLACE (5 AS id) FROM test_table;
SELECT '--';
DESCRIBE (SELECT * REPLACE (5 AS id, 6 as value) FROM test_table);
SELECT * REPLACE (5 AS id, 6 as value) FROM test_table;
SELECT '--';
DESCRIBE (SELECT COLUMNS(id, value) REPLACE (5 AS id, 6 as value) FROM test_table);
SELECT COLUMNS(id, value) REPLACE (5 AS id, 6 as value) FROM test_table;
SELECT 'Combine EXCEPT, REPLACE, APPLY transformers';
SELECT '--';
DESCRIBE (SELECT * EXCEPT id REPLACE (5 AS id, 6 as value) APPLY toString FROM test_table);
SELECT * EXCEPT id REPLACE (5 AS id, 6 as value) APPLY toString FROM test_table;
SELECT '--';
DESCRIBE (SELECT COLUMNS(id, value) EXCEPT id REPLACE (5 AS id, 6 as value) APPLY toString FROM test_table);
SELECT COLUMNS(id, value) EXCEPT id REPLACE (5 AS id, 6 as value) APPLY toString FROM test_table;