-- { echoOn } SELECT value FROM (SELECT tupleElement(value, 'a') AS value FROM test_table); 0 EXPLAIN QUERY TREE SELECT value FROM ( SELECT tupleElement(value, 'a') AS value FROM test_table ); QUERY id: 0 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 1, nodes: 1 COLUMN id: 2, column_name: value, result_type: UInt64, source_id: 3 JOIN TREE QUERY id: 3, alias: __table1, is_subquery: 1 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 4, nodes: 1 FUNCTION id: 5, function_name: tupleElement, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 6, nodes: 2 COLUMN id: 7, column_name: value, result_type: Tuple(a UInt64), source_id: 8 CONSTANT id: 9, constant_value: \'a\', constant_value_type: String JOIN TREE TABLE id: 8, alias: __table2, table_name: default.test_table SELECT '--'; -- EXPLAIN QUERY TREE SELECT value FROM ( SELECT tupleElement(value, 'a') AS value FROM test_table ) SETTINGS optimize_functions_to_subcolumns = 1; QUERY id: 0 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 1, nodes: 1 COLUMN id: 2, column_name: value, result_type: UInt64, source_id: 3 JOIN TREE QUERY id: 3, alias: __table1, is_subquery: 1 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 4, nodes: 1 COLUMN id: 5, column_name: value.a, result_type: UInt64, source_id: 6 JOIN TREE TABLE id: 6, alias: __table2, table_name: default.test_table SETTINGS optimize_functions_to_subcolumns=1 SELECT '--'; -- EXPLAIN QUERY TREE SELECT value FROM ( SELECT tupleElement(value, 'a') AS value FROM test_table SETTINGS optimize_functions_to_subcolumns = 0 ) SETTINGS optimize_functions_to_subcolumns = 1; QUERY id: 0 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 1, nodes: 1 COLUMN id: 2, column_name: value, result_type: UInt64, source_id: 3 JOIN TREE QUERY id: 3, alias: __table1, is_subquery: 1 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 4, nodes: 1 FUNCTION id: 5, function_name: tupleElement, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 6, nodes: 2 COLUMN id: 7, column_name: value, result_type: Tuple(a UInt64), source_id: 8 CONSTANT id: 9, constant_value: \'a\', constant_value_type: String JOIN TREE TABLE id: 8, alias: __table2, table_name: default.test_table SETTINGS optimize_functions_to_subcolumns=0 SETTINGS optimize_functions_to_subcolumns=1 SELECT '--'; -- EXPLAIN QUERY TREE SELECT value FROM ( SELECT tupleElement(value, 'a') AS value FROM test_table ) SETTINGS optimize_functions_to_subcolumns = 0; QUERY id: 0 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 1, nodes: 1 COLUMN id: 2, column_name: value, result_type: UInt64, source_id: 3 JOIN TREE QUERY id: 3, alias: __table1, is_subquery: 1 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 4, nodes: 1 FUNCTION id: 5, function_name: tupleElement, function_type: ordinary, result_type: UInt64 ARGUMENTS LIST id: 6, nodes: 2 COLUMN id: 7, column_name: value, result_type: Tuple(a UInt64), source_id: 8 CONSTANT id: 9, constant_value: \'a\', constant_value_type: String JOIN TREE TABLE id: 8, alias: __table2, table_name: default.test_table SETTINGS optimize_functions_to_subcolumns=0 SELECT '--'; -- EXPLAIN QUERY TREE SELECT value FROM ( SELECT tupleElement(value, 'a') AS value FROM test_table SETTINGS optimize_functions_to_subcolumns = 1 ) SETTINGS optimize_functions_to_subcolumns = 0; QUERY id: 0 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 1, nodes: 1 COLUMN id: 2, column_name: value, result_type: UInt64, source_id: 3 JOIN TREE QUERY id: 3, alias: __table1, is_subquery: 1 PROJECTION COLUMNS value UInt64 PROJECTION LIST id: 4, nodes: 1 COLUMN id: 5, column_name: value.a, result_type: UInt64, source_id: 6 JOIN TREE TABLE id: 6, alias: __table2, table_name: default.test_table SETTINGS optimize_functions_to_subcolumns=1 SETTINGS optimize_functions_to_subcolumns=0