ClickHouse/tests/queries/0_stateless/02890_untuple_column_names.sql

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

49 lines
3.5 KiB
MySQL
Raw Normal View History

2023-10-09 18:31:18 +00:00
-- If the untuple() function has an alias, and if the tuple element has an explicit name, we want to use it to
-- generate the resulting column name.
-- Check all combinations of tuple element alias and untuple() alias. Also to avoid that we generate the same
-- result column names and confuse query analysis (see #26179), test also two untuple() calls in one SElECT
-- with the same types and aliases.
2023-09-30 11:14:09 +00:00
2023-10-08 09:32:02 +00:00
SELECT '-- tuple element alias';
2023-09-30 11:14:09 +00:00
2024-07-12 12:49:26 +00:00
SELECT untuple(tuple(1)::Tuple(a Int)), untuple(tuple('s')::Tuple(a String)) FORMAT Vertical SETTINGS enable_analyzer = 0;
SELECT untuple(tuple(1)::Tuple(a Int)), untuple(tuple('s')::Tuple(a String)) FORMAT Vertical SETTINGS enable_analyzer = 1;
2023-10-09 18:31:18 +00:00
2024-07-12 12:49:26 +00:00
SELECT untuple(tuple(1)::Tuple(a Int)), untuple(tuple(1)::Tuple(a Int)) FORMAT Vertical SETTINGS enable_analyzer = 0; -- { serverError DUPLICATE_COLUMN }
SELECT untuple(tuple(1)::Tuple(a Int)), untuple(tuple(1)::Tuple(a Int)) FORMAT Vertical SETTINGS enable_analyzer = 1; -- Bug: doesn't throw an exception
2023-10-09 18:31:18 +00:00
SELECT '-- tuple element alias + untuple() alias';
2024-07-12 12:49:26 +00:00
SELECT untuple(tuple(1)::Tuple(a Int)) x, untuple(tuple('s')::Tuple(a String)) y FORMAT Vertical SETTINGS enable_analyzer = 0;
SELECT untuple(tuple(1)::Tuple(a Int)) x, untuple(tuple('s')::Tuple(a String)) y FORMAT Vertical SETTINGS enable_analyzer = 1;
2023-10-09 18:31:18 +00:00
2024-07-12 12:49:26 +00:00
SELECT untuple(tuple(1)::Tuple(a Int)) x, untuple(tuple(1)::Tuple(a Int)) x FORMAT Vertical SETTINGS enable_analyzer = 0; -- { serverError DUPLICATE_COLUMN }
SELECT untuple(tuple(1)::Tuple(a Int)) x, untuple(tuple(1)::Tuple(a Int)) x FORMAT Vertical SETTINGS enable_analyzer = 1; -- Bug: doesn't throw an exception
2023-09-29 20:01:23 +00:00
2023-10-08 09:32:02 +00:00
SELECT '-- untuple() alias';
2023-10-09 18:31:18 +00:00
2024-07-12 12:49:26 +00:00
SELECT untuple(tuple(1)::Tuple(Int)) x, untuple(tuple('s')::Tuple(String)) y FORMAT Vertical SETTINGS enable_analyzer = 0;
SELECT untuple(tuple(1)::Tuple(Int)) x, untuple(tuple('s')::Tuple(String)) y FORMAT Vertical SETTINGS enable_analyzer = 1;
2023-10-09 18:31:18 +00:00
2024-07-12 12:49:26 +00:00
SELECT untuple(tuple(1)::Tuple(Int)) x, untuple(tuple(1)::Tuple(Int)) x FORMAT Vertical SETTINGS enable_analyzer = 0; -- { serverError DUPLICATE_COLUMN }
SELECT untuple(tuple(1)::Tuple(Int)) x, untuple(tuple(1)::Tuple(Int)) x FORMAT Vertical SETTINGS enable_analyzer = 1; -- Bug: doesn't throw an exception
2023-09-29 20:01:23 +00:00
2023-10-08 09:32:02 +00:00
SELECT '-- no aliases';
2023-10-09 18:31:18 +00:00
2024-07-12 12:49:26 +00:00
SELECT untuple(tuple(1)::Tuple(Int)), untuple(tuple('s')::Tuple(String)) FORMAT Vertical SETTINGS enable_analyzer = 0;
SELECT untuple(tuple(1)::Tuple(Int)), untuple(tuple('s')::Tuple(String)) FORMAT Vertical SETTINGS enable_analyzer = 1;
2023-10-09 18:31:18 +00:00
2024-07-12 12:49:26 +00:00
SELECT untuple(tuple(1)::Tuple(Int)), untuple(tuple(1)::Tuple(Int)) FORMAT Vertical SETTINGS enable_analyzer = 0; -- { serverError DUPLICATE_COLUMN }
SELECT untuple(tuple(1)::Tuple(Int)), untuple(tuple(1)::Tuple(Int)) FORMAT Vertical SETTINGS enable_analyzer = 1; -- Bug: doesn't throw an exception
2023-09-30 11:14:09 +00:00
2023-10-08 09:32:02 +00:00
SELECT '-- tuple() loses the column names (would be good to fix, see #36773)';
2024-07-12 12:49:26 +00:00
SELECT untuple(tuple(1 as a)) as t FORMAT Vertical SETTINGS enable_analyzer = 0, enable_named_columns_in_function_tuple = 0;
SELECT untuple(tuple(1 as a)) as t FORMAT Vertical SETTINGS enable_analyzer = 1, enable_named_columns_in_function_tuple = 0;
2024-06-18 12:35:33 +00:00
2024-07-12 12:49:26 +00:00
SELECT '-- tuple() with enable_named_columns_in_function_tuple = 1 and enable_analyzer = 1 keeps the column names';
SELECT untuple(tuple(1 as a)) as t FORMAT Vertical SETTINGS enable_analyzer = 1, enable_named_columns_in_function_tuple = 1;
2023-09-29 20:01:23 +00:00
2023-10-08 09:32:02 +00:00
SELECT '-- thankfully JSONExtract() keeps them';
2024-07-12 12:49:26 +00:00
SELECT untuple(JSONExtract('{"key": "value"}', 'Tuple(key String)')) x FORMAT Vertical SETTINGS enable_analyzer = 0;
SELECT untuple(JSONExtract('{"key": "value"}', 'Tuple(key String)')) x FORMAT Vertical SETTINGS enable_analyzer = 1;