SELECT (b AS `cityHash64(a)`) + 10, (b AS b) + 3 FROM column_swap_test_test WHERE b = 1 QUERY id: 0 PROJECTION COLUMNS plus(cityHash64(a), 10) UInt64 plus(b, 3) UInt64 PROJECTION LIST id: 1, nodes: 2 FUNCTION id: 2, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 3, nodes: 2 COLUMN id: 4, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 6, constant_value: UInt64_10, constant_value_type: UInt8 FUNCTION id: 7, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 8, nodes: 2 COLUMN id: 9, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 10, constant_value: UInt64_3, constant_value_type: UInt8 JOIN TREE TABLE id: 5, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 11, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 12, nodes: 2 COLUMN id: 13, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 14, constant_value: UInt64_1, constant_value_type: UInt8 SETTINGS enable_analyzer=1 SELECT cityHash64(a) + 10, b + 3 FROM column_swap_test_test PREWHERE cityHash64(a) = 1 QUERY id: 0 PROJECTION COLUMNS plus(cityHash64(a), 10) UInt64 plus(b, 3) UInt64 PROJECTION LIST id: 1, nodes: 2 FUNCTION id: 2, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 3, nodes: 2 COLUMN id: 4, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 6, constant_value: UInt64_10, constant_value_type: UInt8 FUNCTION id: 7, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 8, nodes: 2 COLUMN id: 9, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 10, constant_value: UInt64_3, constant_value_type: UInt8 JOIN TREE TABLE id: 5, alias: __table1, table_name: default.column_swap_test_test PREWHERE FUNCTION id: 11, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 12, nodes: 2 COLUMN id: 13, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 14, constant_value: UInt64_1, constant_value_type: UInt8 SETTINGS enable_analyzer=1 SELECT (b AS `cityHash64(a)`) + 10, (b AS b) + 3 FROM column_swap_test_test WHERE b = 0 QUERY id: 0 PROJECTION COLUMNS plus(cityHash64(a), 10) UInt64 plus(b, 3) UInt64 PROJECTION LIST id: 1, nodes: 2 FUNCTION id: 2, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 3, nodes: 2 COLUMN id: 4, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 6, constant_value: UInt64_10, constant_value_type: UInt8 FUNCTION id: 7, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 8, nodes: 2 COLUMN id: 9, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 10, constant_value: UInt64_3, constant_value_type: UInt8 JOIN TREE TABLE id: 5, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 11, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 12, nodes: 2 COLUMN id: 13, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 14, constant_value: UInt64_0, constant_value_type: UInt8 SETTINGS enable_analyzer=1 SELECT (b AS `cityHash64(a)`) + 10, (b AS b) + 3 FROM column_swap_test_test WHERE b = 0 QUERY id: 0 PROJECTION COLUMNS plus(cityHash64(a), 10) UInt64 plus(b, 3) UInt64 PROJECTION LIST id: 1, nodes: 2 FUNCTION id: 2, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 3, nodes: 2 COLUMN id: 4, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 6, constant_value: UInt64_10, constant_value_type: UInt8 FUNCTION id: 7, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 8, nodes: 2 COLUMN id: 9, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 10, constant_value: UInt64_3, constant_value_type: UInt8 JOIN TREE TABLE id: 5, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 11, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 12, nodes: 2 COLUMN id: 13, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 14, constant_value: UInt64_0, constant_value_type: UInt8 SETTINGS enable_analyzer=1 SELECT (b AS `cityHash64(a)`) + 10, (b AS b) + 3 FROM column_swap_test_test WHERE b = 1 QUERY id: 0 PROJECTION COLUMNS plus(cityHash64(a), 10) UInt64 plus(b, 3) UInt64 PROJECTION LIST id: 1, nodes: 2 FUNCTION id: 2, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 3, nodes: 2 COLUMN id: 4, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 6, constant_value: UInt64_10, constant_value_type: UInt8 FUNCTION id: 7, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 8, nodes: 2 COLUMN id: 9, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 10, constant_value: UInt64_3, constant_value_type: UInt8 JOIN TREE TABLE id: 5, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 11, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 12, nodes: 2 COLUMN id: 13, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 14, constant_value: UInt64_1, constant_value_type: UInt8 SETTINGS enable_analyzer=1 SELECT (b AS `cityHash64(a)`) + 10 FROM column_swap_test_test WHERE b = 0 QUERY id: 0 PROJECTION COLUMNS plus(cityHash64(a), 10) UInt64 PROJECTION LIST id: 1, nodes: 1 FUNCTION id: 2, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 3, nodes: 2 COLUMN id: 4, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 6, constant_value: UInt64_10, constant_value_type: UInt8 JOIN TREE TABLE id: 5, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 7, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 8, nodes: 2 COLUMN id: 9, column_name: b, result_type: UInt64, source_id: 5 CONSTANT id: 10, constant_value: UInt64_0, constant_value_type: UInt8 SETTINGS enable_analyzer=1 SELECT (cityHash64(a) AS `cityHash64(a)`) + 10, a FROM column_swap_test_test WHERE cityHash64(a) = 0 QUERY id: 0 PROJECTION COLUMNS plus(cityHash64(a), 10) UInt64 a String PROJECTION LIST id: 1, nodes: 2 FUNCTION id: 2, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 3, nodes: 2 FUNCTION id: 4, function_name: cityHash64, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 5, nodes: 1 COLUMN id: 6, column_name: a, result_type: String, source_id: 7 CONSTANT id: 8, constant_value: UInt64_10, constant_value_type: UInt8 COLUMN id: 9, column_name: a, result_type: String, source_id: 7 JOIN TREE TABLE id: 7, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 10, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 11, nodes: 2 FUNCTION id: 12, function_name: cityHash64, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 13, nodes: 1 COLUMN id: 14, column_name: a, result_type: String, source_id: 7 CONSTANT id: 15, constant_value: UInt64_0, constant_value_type: UInt8 SETTINGS enable_analyzer=1 SELECT (cityHash64(a) AS b) + 10, a FROM column_swap_test_test WHERE cityHash64(a) = 0 QUERY id: 0 PROJECTION COLUMNS plus(b, 10) UInt64 a String PROJECTION LIST id: 1, nodes: 2 FUNCTION id: 2, function_name: plus, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 3, nodes: 2 FUNCTION id: 4, function_name: cityHash64, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 5, nodes: 1 COLUMN id: 6, column_name: a, result_type: String, source_id: 7 CONSTANT id: 8, constant_value: UInt64_10, constant_value_type: UInt8 COLUMN id: 9, column_name: a, result_type: String, source_id: 7 JOIN TREE TABLE id: 7, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 10, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 11, nodes: 2 FUNCTION id: 12, function_name: cityHash64, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 13, nodes: 1 COLUMN id: 14, column_name: a, result_type: String, source_id: 7 CONSTANT id: 15, constant_value: UInt64_0, constant_value_type: UInt8 SETTINGS enable_analyzer=1 SELECT a AS `substring(reverse(b), 1, 1)`, a AS a FROM column_swap_test_test WHERE a = \'c\' QUERY id: 0 PROJECTION COLUMNS substring(reverse(b), 1, 1) String a String PROJECTION LIST id: 1, nodes: 2 COLUMN id: 2, column_name: a, result_type: String, source_id: 3 COLUMN id: 4, column_name: a, result_type: String, source_id: 3 JOIN TREE TABLE id: 3, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 5, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 6, nodes: 2 COLUMN id: 7, column_name: a, result_type: String, source_id: 3 CONSTANT id: 8, constant_value: \'c\', constant_value_type: String SETTINGS enable_analyzer=1 SELECT a AS `substring(reverse(b), 1, 1)`, a AS a FROM column_swap_test_test WHERE a = \'c\' QUERY id: 0 PROJECTION COLUMNS substring(reverse(b), 1, 1) String a String PROJECTION LIST id: 1, nodes: 2 COLUMN id: 2, column_name: a, result_type: String, source_id: 3 COLUMN id: 4, column_name: a, result_type: String, source_id: 3 JOIN TREE TABLE id: 3, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 5, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 6, nodes: 2 COLUMN id: 7, column_name: a, result_type: String, source_id: 3 CONSTANT id: 8, constant_value: \'c\', constant_value_type: String SETTINGS enable_analyzer=1 SELECT a AS t1, a AS t2 FROM column_swap_test_test WHERE a = \'c\' QUERY id: 0 PROJECTION COLUMNS t1 String t2 String PROJECTION LIST id: 1, nodes: 2 COLUMN id: 2, column_name: a, result_type: String, source_id: 3 COLUMN id: 4, column_name: a, result_type: String, source_id: 3 JOIN TREE TABLE id: 3, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 5, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 6, nodes: 2 COLUMN id: 7, column_name: a, result_type: String, source_id: 3 CONSTANT id: 8, constant_value: \'c\', constant_value_type: String SETTINGS enable_analyzer=1 SELECT a AS `substring(reverse(b), 1, 1)` FROM column_swap_test_test WHERE a = \'c\' QUERY id: 0 PROJECTION COLUMNS substring(reverse(b), 1, 1) String PROJECTION LIST id: 1, nodes: 1 COLUMN id: 2, column_name: a, result_type: String, source_id: 3 JOIN TREE TABLE id: 3, alias: __table1, table_name: default.column_swap_test_test WHERE FUNCTION id: 4, function_name: equals, function_type: ordinary, result_type: UInt8 ARGUMENTS LIST id: 5, nodes: 2 COLUMN id: 6, column_name: a, result_type: String, source_id: 3 CONSTANT id: 7, constant_value: \'c\', constant_value_type: String SETTINGS enable_analyzer=1 SELECT a FROM t_bad_constraint QUERY id: 0 PROJECTION COLUMNS a UInt32 PROJECTION LIST id: 1, nodes: 1 COLUMN id: 2, column_name: a, result_type: UInt32, source_id: 3 JOIN TREE TABLE id: 3, alias: __table1, table_name: default.t_bad_constraint SETTINGS enable_analyzer=1