ClickHouse/tests/queries/0_stateless/02337_analyzer_columns_basic.sql
2022-12-13 12:48:14 +01:00

102 lines
2.3 KiB
SQL

-- Tags: no-parallel
SET allow_experimental_analyzer = 1;
-- Empty from section
SELECT 'Empty from section';
DESCRIBE (SELECT dummy);
SELECT dummy;
SELECT '--';
DESCRIBE (SELECT one.dummy);
SELECT one.dummy;
SELECT '--';
DESCRIBE (SELECT system.one.dummy);
SELECT system.one.dummy;
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table
(
id UInt64,
value String
) ENGINE=TinyLog;
INSERT INTO test_table VALUES (0, 'Value');
SELECT 'Table access without table name qualification';
SELECT test_id FROM test_table; -- { serverError 47 }
SELECT test_id FROM test_unknown_table; -- { serverError 60 }
DESCRIBE (SELECT id FROM test_table);
SELECT id FROM test_table;
SELECT '--';
DESCRIBE (SELECT value FROM test_table);
SELECT value FROM test_table;
SELECT '--';
DESCRIBE (SELECT id, value FROM test_table);
SELECT id, value FROM test_table;
SELECT 'Table access with table name qualification';
DESCRIBE (SELECT test_table.id FROM test_table);
SELECT test_table.id FROM test_table;
SELECT '--';
DESCRIBE (SELECT test_table.value FROM test_table);
SELECT test_table.value FROM test_table;
SELECT '--';
DESCRIBE (SELECT test_table.id, test_table.value FROM test_table);
SELECT test_table.id, test_table.value FROM test_table;
SELECT '--';
DESCRIBE (SELECT test.id, test.value FROM test_table AS test);
SELECT test.id, test.value FROM test_table AS test;
DROP TABLE test_table;
SELECT 'Table access with database and table name qualification';
DROP DATABASE IF EXISTS 02337_db;
CREATE DATABASE 02337_db;
DROP TABLE IF EXISTS 02337_db.test_table;
CREATE TABLE 02337_db.test_table
(
id UInt64,
value String
) ENGINE=TinyLog;
INSERT INTO 02337_db.test_table VALUES (0, 'Value');
SELECT '--';
DESCRIBE (SELECT test_table.id, test_table.value FROM 02337_db.test_table);
SELECT test_table.id, test_table.value FROM 02337_db.test_table;
SELECT '--';
DESCRIBE (SELECT 02337_db.test_table.id, 02337_db.test_table.value FROM 02337_db.test_table);
SELECT 02337_db.test_table.id, 02337_db.test_table.value FROM 02337_db.test_table;
SELECT '--';
DESCRIBE (SELECT test_table.id, test_table.value FROM 02337_db.test_table AS test_table);
SELECT test_table.id, test_table.value FROM 02337_db.test_table AS test_table;
DROP TABLE 02337_db.test_table;
DROP DATABASE 02337_db;